Class: Sportradar::Api::Mma::Schedule

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/mma/schedule.rb

Constant Summary collapse

KEYS_SCHED =
["id", "name", "scheduled", "venue", "league", "fights"]

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, **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

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/mma/schedule.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/sportradar/api/mma/schedule.rb', line 5

def name
  @name
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/mma/schedule.rb', line 5

def response
  @response
end

#scheduledObject

Returns the value of attribute scheduled.



5
6
7
# File 'lib/sportradar/api/mma/schedule.rb', line 5

def scheduled
  @scheduled
end

#venueObject

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

#apiObject



30
31
32
# File 'lib/sportradar/api/mma/schedule.rb', line 30

def api
  @api ||= Sportradar::Api::Mma.new
end

#eventsObject



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