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
|
# File 'lib/kekka/kekka.rb', line 4
def self.parse string_or_io
document = Nokogiri.parse string_or_io
result = Kekka.new
result[:persons] = hash_from document, 'person'
result[:boats] = hash_from document, 'boat'
result[:teams] = hash_from document, 'team' do |team_hash, node|
team_hash[:crew] = array_from node, 'crew'
end
result[:events] = hash_from document, 'event' do |event_hash, node|
event_hash[:races] = hash_from node, 'race'
event_hash[:divisions] = hash_from node, 'division' do |division_hash, node|
division_hash[:raceresults] = array_from node, 'raceresult' do |hash, node|
team = result[:teams][hash['teamid']]
hash['boatid'] = team['boatid']
end
division_hash[:seriesresults] = array_from node, 'seriesresult'
division_hash['scoretype'] ||= 'points'
end
end
result.update_boats_with_class
result
end
|