Class: Sportradar::Api::Mma
- Defined in:
- lib/sportradar/api/mma.rb,
lib/sportradar/api/mma/event.rb,
lib/sportradar/api/mma/fight.rb,
lib/sportradar/api/mma/judge.rb,
lib/sportradar/api/mma/score.rb,
lib/sportradar/api/mma/venue.rb,
lib/sportradar/api/mma/league.rb,
lib/sportradar/api/mma/result.rb,
lib/sportradar/api/mma/roster.rb,
lib/sportradar/api/mma/fighter.rb,
lib/sportradar/api/mma/referee.rb,
lib/sportradar/api/mma/schedule.rb
Defined Under Namespace
Classes: Event, Fight, Fighter, Judge, League, Referee, Result, Roster, Schedule, Score, Venue
Instance Attribute Summary collapse
-
#access_level ⇒ Object
Returns the value of attribute access_level.
-
#error ⇒ Object
Returns the value of attribute error.
-
#league ⇒ Object
Returns the value of attribute league.
-
#simulation ⇒ Object
Returns the value of attribute simulation.
Attributes inherited from Request
#qps_allotted, #qps_current, #quota_allotted, #quota_current
Instance Method Summary collapse
- #generate_simulation_event(event_id = "8f85ecc5-0d4d-470b-b357-075cc7e7bedd") ⇒ Object
-
#get_data(url) ⇒ Object
def active_simulation game = simulation_games.lazy.map {|game_id| game_boxscore game_id }.find{ |game| game.status == ‘inprogress’} if game puts “Live Game: #gamegame.summarygame.summary.homegame.summary.home.full_name vs #gamegame.summarygame.summary.awaygame.summary.away.full_name.
-
#initialize(access_level = 't') ⇒ Mma
constructor
A new instance of Mma.
- #participants ⇒ Object
- #schedule ⇒ Object
- #statistics(event_id = "8f85ecc5-0d4d-470b-b357-075cc7e7bedd") ⇒ Object
Methods inherited from Request
#get, #get_request_info, #parse_usage, #sim!, #usage
Constructor Details
#initialize(access_level = 't') ⇒ Mma
Returns a new instance of Mma.
6 7 8 9 10 |
# File 'lib/sportradar/api/mma.rb', line 6 def initialize(access_level = 't') @league = 'mma' raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level @access_level = access_level end |
Instance Attribute Details
#access_level ⇒ Object
Returns the value of attribute access_level.
4 5 6 |
# File 'lib/sportradar/api/mma.rb', line 4 def access_level @access_level end |
#error ⇒ Object
Returns the value of attribute error.
4 5 6 |
# File 'lib/sportradar/api/mma.rb', line 4 def error @error end |
#league ⇒ Object
Returns the value of attribute league.
4 5 6 |
# File 'lib/sportradar/api/mma.rb', line 4 def league @league end |
#simulation ⇒ Object
Returns the value of attribute simulation.
4 5 6 |
# File 'lib/sportradar/api/mma.rb', line 4 def simulation @simulation end |
Instance Method Details
#generate_simulation_event(event_id = "8f85ecc5-0d4d-470b-b357-075cc7e7bedd") ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sportradar/api/mma.rb', line 35 def generate_simulation_event(event_id = "8f85ecc5-0d4d-470b-b357-075cc7e7bedd") event = Event.new({ 'id' => event_id }) i = 0 base_path = "simulations/mma/#{event_id}" FileUtils.mkdir_p(base_path) loop do t = Time.now print "#{t}: Data pull #{i+=1}\r" res = event.get_stats.body File.write("#{base_path}/#{t.to_i}.xml", res) wait = (t.to_i + 60 - Time.now.to_i) wait.times do |j| print "#{t}: Data pull #{i} complete, #{wait - j} seconds until next.\r" sleep 1 end puts end end |
#get_data(url) ⇒ Object
def active_simulation
game = simulation_games.lazy.map {|game_id| game_boxscore game_id }.find{ |game| game.status == 'inprogress'}
if game
puts "Live Game: #{game.summary.home.full_name} vs #{game.summary.away.full_name}. Q#{game.quarter} #{game.clock}. game_id='#{game.id}'"
game
else
puts "No active simulation"
end
end
152 153 154 |
# File 'lib/sportradar/api/mma.rb', line 152 def get_data(url) get request_url(url) end |
#participants ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/sportradar/api/mma.rb', line 21 def participants response = get request_url("profiles") if response.success? && response['profile'] Sportradar::Api::Mma::Roster.new(response['profile'], api: self) else @error = response end end |
#schedule ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/sportradar/api/mma.rb', line 12 def schedule response = get request_url("schedule") if response.success? && response['schedule'] Sportradar::Api::Mma::Schedule.new(response['schedule'], api: self) else @error = response end end |
#statistics(event_id = "8f85ecc5-0d4d-470b-b357-075cc7e7bedd") ⇒ Object
30 31 32 33 34 |
# File 'lib/sportradar/api/mma.rb', line 30 def statistics(event_id = "8f85ecc5-0d4d-470b-b357-075cc7e7bedd") event_hash = {"id" => event_id } # => UFC 205 - McGregor/Alvarez event = Event.new({ 'id' => event_id }) event.get_stats end |