Class: Sportradar::Api::Soccer::Season

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/soccer/season.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data

Constructor Details

#initialize(data = {}, league_group: nil, **opts) ⇒ Season

Returns a new instance of Season.



7
8
9
10
11
12
13
14
# File 'lib/sportradar/api/soccer/season.rb', line 7

def initialize(data = {}, league_group: nil, **opts)
  @response     = data
  @id           = data["id"]
  @api          = opts[:api]
  @league_group = league_group || data['league_group'] || @api&.league_group

  update(data, **opts)
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def category
  @category
end

#current_seasonObject (readonly)

Returns the value of attribute current_season.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def current_season
  @current_season
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def id
  @id
end

#league_groupObject (readonly)

Returns the value of attribute league_group.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def league_group
  @league_group
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def name
  @name
end

#season_coverage_infoObject (readonly)

Returns the value of attribute season_coverage_info.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def season_coverage_info
  @season_coverage_info
end

#tournament_idObject (readonly)

Returns the value of attribute tournament_id.



5
6
7
# File 'lib/sportradar/api/soccer/season.rb', line 5

def tournament_id
  @tournament_id
end

Instance Method Details

#apiObject



47
48
49
# File 'lib/sportradar/api/soccer/season.rb', line 47

def api
  @api ||= Sportradar::Api::Soccer::Api.new(league_group: @league_group)
end

#current?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/sportradar/api/soccer/season.rb', line 43

def current?
  !!@current
end

#get_tournament_id(data, **opts) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/sportradar/api/soccer/season.rb', line 33

def get_tournament_id(data, **opts)
  @tournament_id ||= if opts[:tournament]
    opts[:tournament].id
  elsif data['tournament_id']
    data['tournament_id']
  elsif data['tournament']
    data.dig('tournament', 'id')
  end
end

#update(data, **opts) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sportradar/api/soccer/season.rb', line 16

def update(data, **opts)
  @league_group       = opts[:league_group] || data['league_group'] || @league_group
  @id                 = data['id'] || data['season_id'] || @id
  @current            = opts[:current] || @current
  get_tournament_id(data, **opts)

  @name               = data['name']                || @name
  @start_date         = data['start_date']          || @start_date
  @end_date           = data['end_date']            || @end_date
  @year               = data['year']                || @year
  @scheduled          = data['scheduled']           || @scheduled
  @played             = data['played']              || @played
  @max_coverage_level = data['max_coverage_level']  || @max_coverage_level
  @max_covered        = data['max_covered']         || @max_covered
  @min_coverage_level = data['min_coverage_level']  || @min_coverage_level
end