Class: Sportradar::Api::Football::Ncaafb::Division
- Defined in:
- lib/sportradar/api/football/ncaafb/division.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
Returns the value of attribute alias.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #conference(code_name) ⇒ Object
- #conferences ⇒ Object
- #conferences_by_name ⇒ Object
-
#initialize(data, **opts) ⇒ Division
constructor
A new instance of Division.
- #teams ⇒ Object
- #update(data, **opts) ⇒ Object
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, **opts) ⇒ Division
Returns a new instance of Division.
8 9 10 11 12 13 14 15 16 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 8 def initialize(data, **opts) # @response = data @api = opts[:api] @id = data["id"] @name = data["name"] @alias = data["alias"] || data["id"] update(data, **opts) end |
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
6 7 8 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 6 def alias @alias end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 6 def name @name end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 6 def response @response end |
Instance Method Details
#conference(code_name) ⇒ Object
26 27 28 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 26 def conference(code_name) conferences_by_name[code_name] end |
#conferences ⇒ Object
22 23 24 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 22 def conferences @conferences_hash.values end |
#conferences_by_name ⇒ Object
30 31 32 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 30 def conferences_by_name @conferences_by_name ||= conferences.map { |c| [c.id, c] }.to_h end |
#teams ⇒ Object
34 35 36 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 34 def teams conferences.flat_map(&:teams) end |
#update(data, **opts) ⇒ Object
18 19 20 |
# File 'lib/sportradar/api/football/ncaafb/division.rb', line 18 def update(data, **opts) @conferences_hash = create_data({}, data["conferences"], klass: Conference, division: self, api: @api) if data["conferences"] end |