Class: Sportradar::Api::Mma::Schedule
- Defined in:
- lib/sportradar/api/mma/schedule.rb
Constant Summary collapse
- KEYS_SCHED =
["id", "name", "scheduled", "venue", "league", "fights"]
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#response ⇒ Object
Returns the value of attribute response.
-
#scheduled ⇒ Object
Returns the value of attribute scheduled.
-
#venue ⇒ Object
Returns the value of attribute venue.
Instance Method Summary collapse
- #api ⇒ Object
- #events ⇒ Object
-
#initialize(data, **opts) ⇒ Schedule
constructor
A new instance of Schedule.
- #update(data) ⇒ Object
- #update_events(data) ⇒ 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) ⇒ Schedule
Returns a new instance of Schedule.
7 8 9 10 11 12 13 14 |
# File 'lib/sportradar/api/mma/schedule.rb', line 7 def initialize(data, **opts) @response = data @api = opts[:api] @generated = response['generated'] @events_hash = {} update(data) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/mma/schedule.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sportradar/api/mma/schedule.rb', line 5 def name @name end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/mma/schedule.rb', line 5 def response @response end |
#scheduled ⇒ Object
Returns the value of attribute scheduled.
5 6 7 |
# File 'lib/sportradar/api/mma/schedule.rb', line 5 def scheduled @scheduled end |
#venue ⇒ Object
Returns the value of attribute venue.
5 6 7 |
# File 'lib/sportradar/api/mma/schedule.rb', line 5 def venue @venue end |
Instance Method Details
#api ⇒ Object
30 31 32 |
# File 'lib/sportradar/api/mma/schedule.rb', line 30 def api @api ||= Sportradar::Api::Mma.new end |
#events ⇒ Object
16 17 18 19 |
# File 'lib/sportradar/api/mma/schedule.rb', line 16 def events @events_hash ||= update_events(response) @events_hash.values end |
#update(data) ⇒ Object
21 22 23 24 25 |
# File 'lib/sportradar/api/mma/schedule.rb', line 21 def update(data) update_events(data) self end |
#update_events(data) ⇒ Object
27 28 29 |
# File 'lib/sportradar/api/mma/schedule.rb', line 27 def update_events(data) create_data(@events_hash, response.dig('events', 'event'), klass: Event, api: api, schedule: self) end |