class LolesportsApi::Match
Constants
- API_URL
Attributes
blue_team[R]
date_time[R]
games[R]
id[R]
is_finished[R]
is_live[R]
live_streams[R]
max_games[R]
name[R]
polldaddy_id[R]
red_team[R]
round[R]
tournament[RW]
url[R]
winner_id[R]
Public Class Methods
find(match_id)
click to toggle source
Calls superclass method
LolesportsApi::BaseApiObject::find
# File lib/lolesports-api/match.rb, line 34 def self.find(match_id) super @base_object.prepare_games(@attributes) @base_object end
new(attributes = {})
click to toggle source
# File lib/lolesports-api/match.rb, line 12 def initialize(attributes = {}) @id = (attributes['id'] || attributes['matchId']).to_i @date_time = parse_datetime(attributes['dateTime']) @is_finished = (attributes['isFinished'] == '1' ? true : false) @is_live = attributes['isLive'] @live_streams = attributes['liveStreams'] @max_games = attributes['maxGames'] @name = attributes['name'] @polldaddy_id = attributes['polldaddyId'] @tournament = LolesportsApi::Tournament.new(attributes['tournament']) @url = attributes['url'] @winner_id = attributes['winnerId'].to_i if attributes['tournament'] @round = attributes['tournament']['round'].to_i end prepare_teams(attributes['contestants']) prepare_games(attributes) self end
Public Instance Methods
prepare_games(attrs)
click to toggle source
# File lib/lolesports-api/match.rb, line 40 def prepare_games(attrs) return unless attrs['games'] && attrs['games'].any? @games = [] attrs['games'].each_value do |game| @games << LolesportsApi::Game.new(game) end end
prepare_teams(teams)
click to toggle source
# File lib/lolesports-api/match.rb, line 48 def prepare_teams(teams) return unless teams @blue_team = LolesportsApi::Team.new(teams['blue']) if teams['blue'] @red_team = LolesportsApi::Team.new(teams['red']) if teams['red'] end