Class: Sportradar::Api::Football::Week

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/football/week.rb

Direct Known Subclasses

Ncaafb::Week, Nfl::Week

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

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

Constructor Details

#initialize(data = {}, **opts) ⇒ Week

Returns a new instance of Week.



11
12
13
14
15
16
17
18
19
20
# File 'lib/sportradar/api/football/week.rb', line 11

def initialize(data = {}, **opts)
  # @response = data
  @api        = opts[:api]
  @id         = data['id']
  @hierarchy  = opts[:hierarchy]

  @games_hash = {}

  update(data, **opts)
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def api
  @api
end

#hierarchyObject

Returns the value of attribute hierarchy.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def hierarchy
  @hierarchy
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def id
  @id
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def number
  @number
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def response
  @response
end

#sequenceObject

Returns the value of attribute sequence.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def sequence
  @sequence
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def type
  @type
end

#yearObject

Returns the value of attribute year.



5
6
7
# File 'lib/sportradar/api/football/week.rb', line 5

def year
  @year
end

Instance Method Details

#all_attributesObject



7
8
9
# File 'lib/sportradar/api/football/week.rb', line 7

def all_attributes
  [:number]
end

#gamesObject



33
34
35
# File 'lib/sportradar/api/football/week.rb', line 33

def games
  @games_hash.values
end

#update(data, source: nil, **opts) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/sportradar/api/football/week.rb', line 22

def update(data, source: nil, **opts)
  # update stuff
  @year = opts[:hierarchy].season_year  if opts[:hierarchy]
  @type = opts[:hierarchy].season       if opts[:hierarchy]

  @number   = data['number'] || data['title'] || @number
  @sequence = data['sequence'] || @sequence || @number

  create_data(@games_hash, data['games'],   klass: game_class,   week: self, api: api)
end