3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jkf/converter/kif.rb', line 3
def convert(jkf)
hash = if jkf.is_a?(Hash)
jkf
else
JSON.parse(jkf)
end
@forks = []
players_flag = :sengo
hash['header'] && hash['header'].keys.find { |key| key =~ /[上下]手/ } && players_flag = :uwasimo
@players = if players_flag == :uwasimo
['下', '上']
else
['先', '後']
end
@header2 = []
result = ''
result += (hash['header']) if hash['header']
result += convert_initial(hash['initial']) if hash['initial']
result += @header2.join
result += "手数----指手---------消費時間--\n"
result += convert_moves(hash['moves'])
if @forks.size > 0
result += "\n"
result += @forks.join("\n")
end
result
end
|