lib/sportradar/api/soccer/tournament.rb in sportradar-api-0.13.0 vs lib/sportradar/api/soccer/tournament.rb in sportradar-api-0.13.1

- old
+ new

@@ -1,10 +1,12 @@ module Sportradar module Api module Soccer class Tournament < Data attr_reader :id, :league_group, :name, :category + alias :display_name :name + alias :alias :name def initialize(data = {}, league_group: nil, **opts) @response = data @id = data["id"] @api = opts[:api] @@ -22,12 +24,12 @@ def update(data, **opts) if data['tournament'] update(data['tournament']) end - @name = data["name"] - @category = data['category'] || @category + @name = data["name"] || @name + @category = data['category'] || @category parse_info(data) parse_season(data) parse_results(data) parse_schedule(data) @@ -36,10 +38,22 @@ def seasons @seasons_hash.values end + def schedule + return self if @schedule_retrieved + get_schedule + self + end + + def year + if current_season&.year&.split('/')&.last + 2000 + current_season.year.split('/').last.to_i + end + end + def standings(type = nil) if type @standings_hash[type] else @standings_hash.values @@ -148,9 +162,10 @@ def get_schedule data = api.get_data(path_schedule).to_h ingest_schedule(data) end def ingest_schedule(data) + @schedule_retrieved = true update(data) # TODO parse the rest of the data. keys: ["tournament", "sport_events"] data end def queue_schedule