1 def analyzujriadokhlavicky(riadok)
\r
6 dlzkar = riadok.length
\r
8 puts "analyzujeme -> {" + riadok + "} "
\r
9 puts "dlzkar -> {" + dlzkar.to_s + "} "
\r
13 #puts "riadok[0] -> {" + riadok[0].to_s + "} "
\r
14 #puts "riadok[dlzkar-1] -> {" + riadok[dlzkar-1].to_s + "} "
\r
16 if (riadok[0].chr.to_s != "[") or (riadok[dlzkar-1].chr.to_s != "]")
\r
22 while ((riadok[pos].chr.to_s ==" ") or (riadok[pos].chr.to_s == "\t"))
\r
30 puts "pos -> {" + pos.to_s + "} "
\r
33 while ((riadok[pos].chr.to_s !=" ") and (riadok[pos].chr.to_s != "\t"))
\r
35 puts "riadok[pos] -> " + riadok[pos].to_s + "(" + riadok[pos].chr + ")"
\r
36 puts "pos -> {" + pos.to_s + "}, tagname -> {" + tagname + "}"
\r
38 tagname = tagname + riadok[pos].chr.to_s
\r
46 puts "tagname -> {" + tagname + "} "
\r
51 def analyzujhlavicku(hlavicka)
\r
54 hlavicka.each_line do |riadok|
\r
55 result = analyzujriadokhlavicky(riadok.chomp)
\r
56 if (result == "ERR")
\r
64 def analyzujtahy(tahy)
\r
70 def analyzuj(pgnsubor)
\r
80 pgnsubor.each_line do |riadok|
\r
82 if (riadok.strip.length !=0)
\r
84 if (citamehlavicku == 0)
\r
86 hlavicka = hlavicka + riadok
\r
88 elsif (citamehlavicku == 1)
\r
90 hlavicka = hlavicka + riadok
\r
92 elsif ((citamehlavicku==2) and (citametahy==0))
\r
95 tahy = tahy + riadok
\r
97 elsif ((citamehlavicku==2) and (citametahy==1))
\r
99 tahy = tahy + riadok
\r
105 if (citamehlavicku==1)
\r
107 elsif (citametahy==1)
\r
121 result = analyzujhlavicku(hlavicka)
\r
126 if (result == "ok")
\r
127 result = analyzujtahy(tahy)
\r
138 puts "zadaj meno suboru: PGN.TXT"
\r
139 filename = "pgn.txt"
\r
140 myfile = File.open(filename,"r")
\r
141 pgnsubor = myfile.read
\r
145 vysledok=analyzuj(pgnsubor)
\r