class LolesportsApi::Tournament

Constants

API_URL

Attributes

contestants[R]
date_begin[R]
date_end[R]
id[R]
is_finished[R]
matches[R]
name[R]
name_public[R]
no_vods[R]
published[R]
season[R]
winner[R]

Public Class Methods

find(tournament_id) click to toggle source
Calls superclass method LolesportsApi::BaseApiObject::find
# File lib/lolesports-api/tournament.rb, line 26
def self.find(tournament_id)
  super
  if @attributes['contestants'] && @attributes['contestants'].any?
    @attributes['contestants'].each_value do |contestant|
      @base_object.contestants << LolesportsApi::Team.new(contestant)
    end
  end
  @base_object
end
new(attributes) click to toggle source
# File lib/lolesports-api/tournament.rb, line 9
def initialize(attributes)
  @id = attributes['id'].to_i
  @contestants = []
  @date_begin = parse_datetime(attributes['dateBegin'])
  @date_end = parse_datetime(attributes['dateEnd'])
  @is_finished = attributes['isFinished']
  @name = attributes['name']
  @name_public = attributes['namePublic']
  @no_vods = attributes['noVods']
  @published = attributes['published']
  @season = attributes['season']
  @winner = attributes['winner'].to_i
  @matches = []

  self
end

Public Instance Methods

find_matches() click to toggle source
# File lib/lolesports-api/tournament.rb, line 36
def find_matches
  response = Faraday.get("#{SCHEDULE_URL}?tournamentId=#{@id}")
  matches_json = JSON.parse(response.body)
  matches_json.each_value do |match|
    @matches << LolesportsApi::Match.new(match)
  end
  @matches
end