class LolesportsApi::Play

Attributes

assists[R]
champion_id[R]
deaths[R]
end_level[R]
items[R]
kda[R]
kills[R]
minions_killed[R]
name[R]
photo_url[R]
player[R]
player_id[R]
spell0[R]
spell1[R]
team_id[R]
total_gold[R]

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/lolesports-api/play.rb, line 8
def initialize(attributes = {})
  @assists = attributes['assists']
  @champion_id = attributes['championId']
  @deaths = attributes['deaths']
  @end_level = attributes['endLevel']
  @player_id = attributes['id']
  @items = processed_items(attributes)
  @kda = attributes['kda']
  @kills = attributes['kills']
  @minions_killed = attributes['minionsKilled']
  @name = attributes['name']
  @photo_url = attributes['photoURL']
  @spell0 = attributes['spell0'].to_i
  @spell1 = attributes['spell1'].to_i
  @team_id = attributes['teamId']
  @total_gold = attributes['totalGold']

  @player = prepare_player
end

Private Instance Methods

prepare_player() click to toggle source
# File lib/lolesports-api/play.rb, line 38
def prepare_player
  LolesportsApi::Player.new(
    'id' => @player_id,
    'name' => @name,
    'photoUrl' => @photo_url,
    'teamId' => @team_id
  )
end
processed_items(attrs) click to toggle source
# File lib/lolesports-api/play.rb, line 30
def processed_items(attrs)
  collected_items = []
  attrs.each do |key, value|
    collected_items << value.to_i if key.match(/^items\d$/)
  end
  collected_items
end