class LolesportsApi::League

Constants

API_URL

Attributes

color[R]
default_series_id[R]
default_tournament_id[R]
id[R]
international_live_stream[R]
label[R]
league_image[R]
league_series[R]
league_tournaments[R]
menu_weight[R]
no_vods[R]
published[R]
short_name[R]
url[R]

Public Class Methods

all() click to toggle source
# File lib/lolesports-api/league.rb, line 44
def self.all
  response = Faraday.get("#{API_URL}.json?parameters%5Bmethod%5D=all")
  leagues_json = JSON.parse(response.body)
  leagues = []
  leagues_json['leagues'].each do |league|
    leagues << new(league)
  end
  leagues
end
find(league_id) click to toggle source
Calls superclass method LolesportsApi::BaseApiObject::find
# File lib/lolesports-api/league.rb, line 31
def self.find(league_id)
  super
  @attributes['leagueTournaments'].each do |tournament|
    @base_object.league_tournaments <<
      LolesportsApi::Tournament.new('id' => tournament)
  end
  @attributes['leagueSeries'].each do |series|
    @base_object.league_series <<
      LolesportsApi::Series.new('id' => series)
  end
  @base_object
end
new(attributes) click to toggle source
# File lib/lolesports-api/league.rb, line 11
def initialize(attributes)
  @id = attributes['id'].to_i
  @color = attributes['color']
  @default_series_id = attributes['defaultSeriesId'].to_i
  @default_tournament_id = attributes['defaultTournamentId'].to_i
  # International Live Stream is one giant cluster, watch out.
  @international_live_stream = attributes['internationalLiveStream']
  @label = attributes['label']
  @league_image = attributes['leagueImage']
  @league_series = []
  @league_tournaments = []
  @menu_weight = attributes['menuWeight']
  @no_vods = attributes['noVods']
  @published = attributes['published']
  @short_name = attributes['shortName']
  @url = attributes['url']

  self
end

Public Instance Methods

name() click to toggle source
# File lib/lolesports-api/league.rb, line 54
def name
  @label
end
series() click to toggle source
# File lib/lolesports-api/league.rb, line 58
def series
  @league_series
end
tournaments() click to toggle source
# File lib/lolesports-api/league.rb, line 62
def tournaments
  @league_tournaments
end