lib/sportradar/api/soccer/tournament_group.rb in sportradar-api-0.1.38 vs lib/sportradar/api/soccer/tournament_group.rb in sportradar-api-0.9.0
- old
+ new
@@ -14,12 +14,11 @@
@top_goals = parse_players(data["top_goals"]["player"]) if data["top_goals"] && data["top_goals"]["player"]
@top_own_goals = parse_players(data["top_own_goals"]["player"]) if data["top_own_goals"] && data["top_own_goals"]["player"]
@top_assists = parse_players(data["top_assists"]["player"]) if data["top_assists"] && data["top_assists"]["player"]
@top_cards = parse_players(data["top_cards"]["player"]) if data["top_cards"] && data["top_cards"]["player"]
@top_points = parse_players(data["top_points"]["player"]) if data["top_points"] && data["top_points"]["player"]
- set_tournaments
-
+ @tournaments = parse_into_array(selector: response["tournaments"], klass: Sportradar::Api::Soccer::Tournament) if response["tournaments"]
end
private
def parse_players(field_to_parse)
@@ -28,18 +27,9 @@
elsif field_to_parse.is_a?(Hash)
[ Sportradar::Api::Soccer::Player.new(field_to_parse) ]
end
end
- def set_tournaments
- if response["tournament"]
- if response["tournament"].is_a?(Array)
- @tournaments = response["tournament"].map {|x| Sportradar::Api::Soccer::Tournament.new x }
- elsif response["tournament"].is_a?(Hash)
- @tournaments = [ Sportradar::Api::Soccer::Tournament.new(response["tournament"]) ]
- end
- end
- end
end
end
end