Class: LolesportsApi::Game
- Inherits:
-
BaseApiObject
- Object
- BaseApiObject
- LolesportsApi::Game
- Defined in:
- lib/lolesports-api/game.rb
Constant Summary collapse
- API_URL =
'http://na.lolesports.com/api/game'
Constants inherited from BaseApiObject
Instance Attribute Summary collapse
-
#blue_team ⇒ Object
Returns the value of attribute blue_team.
-
#date_time ⇒ Object
readonly
Returns the value of attribute date_time.
-
#game_length ⇒ Object
readonly
Returns the value of attribute game_length.
-
#game_number ⇒ Object
readonly
Returns the value of attribute game_number.
-
#has_vod ⇒ Object
readonly
Returns the value of attribute has_vod.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#legs_url ⇒ Object
readonly
Returns the value of attribute legs_url.
-
#match_id ⇒ Object
readonly
Returns the value of attribute match_id.
-
#max_games ⇒ Object
readonly
Returns the value of attribute max_games.
-
#no_vods ⇒ Object
readonly
Returns the value of attribute no_vods.
-
#platform_game_id ⇒ Object
readonly
Returns the value of attribute platform_game_id.
-
#platform_id ⇒ Object
readonly
Returns the value of attribute platform_id.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#red_team ⇒ Object
Returns the value of attribute red_team.
-
#tournament ⇒ Object
readonly
Returns the value of attribute tournament.
-
#vods ⇒ Object
readonly
Returns the value of attribute vods.
-
#winner_id ⇒ Object
readonly
Returns the value of attribute winner_id.
-
#youtube_url ⇒ Object
readonly
Returns the value of attribute youtube_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Game
constructor
A new instance of Game.
- #prepare_teams(attrs) ⇒ Object
Methods inherited from BaseApiObject
Constructor Details
#initialize(attributes = {}) ⇒ Game
Returns a new instance of Game.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lolesports-api/game.rb', line 13 def initialize(attributes = {}) @id = attributes['id'].to_i @game_length = attributes['gameLength'].to_i @game_number = attributes['gameNumber'].to_i @legs_url = attributes['legsUrl'] @match_id = attributes['matchId'].to_i @max_games = attributes['maxGames'].to_i @no_vods = (attributes['noVods'] == '1' ? true : false) @platform_game_id = attributes['platformGameId'] @platform_id = attributes['platformId'] @players = [] @tournament = attributes['tournament'] || {} @vods = attributes['vods'] || {} @has_vod = attributes['hasVod'] @winner_id = parse_winner_id(attributes['winnerId']) @date_time = parse_datetime(attributes['dateTime']) @youtube_url = parse_vods(attributes, 'youtube') prepare_teams(attributes) self end |
Instance Attribute Details
#blue_team ⇒ Object
Returns the value of attribute blue_team.
9 10 11 |
# File 'lib/lolesports-api/game.rb', line 9 def blue_team @blue_team end |
#date_time ⇒ Object (readonly)
Returns the value of attribute date_time.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def date_time @date_time end |
#game_length ⇒ Object (readonly)
Returns the value of attribute game_length.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def game_length @game_length end |
#game_number ⇒ Object (readonly)
Returns the value of attribute game_number.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def game_number @game_number end |
#has_vod ⇒ Object (readonly)
Returns the value of attribute has_vod.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def has_vod @has_vod end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def id @id end |
#legs_url ⇒ Object (readonly)
Returns the value of attribute legs_url.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def legs_url @legs_url end |
#match_id ⇒ Object (readonly)
Returns the value of attribute match_id.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def match_id @match_id end |
#max_games ⇒ Object (readonly)
Returns the value of attribute max_games.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def max_games @max_games end |
#no_vods ⇒ Object (readonly)
Returns the value of attribute no_vods.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def no_vods @no_vods end |
#platform_game_id ⇒ Object (readonly)
Returns the value of attribute platform_game_id.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def platform_game_id @platform_game_id end |
#platform_id ⇒ Object (readonly)
Returns the value of attribute platform_id.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def platform_id @platform_id end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def players @players end |
#red_team ⇒ Object
Returns the value of attribute red_team.
9 10 11 |
# File 'lib/lolesports-api/game.rb', line 9 def red_team @red_team end |
#tournament ⇒ Object (readonly)
Returns the value of attribute tournament.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def tournament @tournament end |
#vods ⇒ Object (readonly)
Returns the value of attribute vods.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def vods @vods end |
#winner_id ⇒ Object (readonly)
Returns the value of attribute winner_id.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def winner_id @winner_id end |
#youtube_url ⇒ Object (readonly)
Returns the value of attribute youtube_url.
3 4 5 |
# File 'lib/lolesports-api/game.rb', line 3 def youtube_url @youtube_url end |
Class Method Details
.find(game_id) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lolesports-api/game.rb', line 36 def self.find(game_id) super @base_object.prepare_teams(@attributes) if @attributes['players'] && @attributes['players'].any? @attributes['players'].each_value do |player| @base_object.players << LolesportsApi::Play.new(player) end end @base_object end |
Instance Method Details
#prepare_teams(attrs) ⇒ Object
47 48 49 50 51 |
# File 'lib/lolesports-api/game.rb', line 47 def prepare_teams(attrs) return unless attrs['contestants'] @blue_team = LolesportsApi::Team.new(attrs['contestants']['blue']) @red_team = LolesportsApi::Team.new(attrs['contestants']['red']) end |