Class: LolesportsApi::Tournament
- Inherits:
-
BaseApiObject
- Object
- BaseApiObject
- LolesportsApi::Tournament
- Defined in:
- lib/lolesports-api/tournament.rb
Constant Summary collapse
- API_URL =
'http://na.lolesports.com/api/tournament'
Constants inherited from BaseApiObject
Instance Attribute Summary collapse
-
#contestants ⇒ Object
readonly
Returns the value of attribute contestants.
-
#date_begin ⇒ Object
readonly
Returns the value of attribute date_begin.
-
#date_end ⇒ Object
readonly
Returns the value of attribute date_end.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_finished ⇒ Object
readonly
Returns the value of attribute is_finished.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_public ⇒ Object
readonly
Returns the value of attribute name_public.
-
#no_vods ⇒ Object
readonly
Returns the value of attribute no_vods.
-
#published ⇒ Object
readonly
Returns the value of attribute published.
-
#season ⇒ Object
readonly
Returns the value of attribute season.
-
#winner ⇒ Object
readonly
Returns the value of attribute winner.
Class Method Summary collapse
Instance Method Summary collapse
- #find_matches ⇒ Object
-
#initialize(attributes) ⇒ Tournament
constructor
A new instance of Tournament.
Methods inherited from BaseApiObject
Constructor Details
#initialize(attributes) ⇒ Tournament
Returns a new instance of Tournament.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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 |
Instance Attribute Details
#contestants ⇒ Object (readonly)
Returns the value of attribute contestants.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def contestants @contestants end |
#date_begin ⇒ Object (readonly)
Returns the value of attribute date_begin.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def date_begin @date_begin end |
#date_end ⇒ Object (readonly)
Returns the value of attribute date_end.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def date_end @date_end end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def id @id end |
#is_finished ⇒ Object (readonly)
Returns the value of attribute is_finished.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def is_finished @is_finished end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def matches @matches end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def name @name end |
#name_public ⇒ Object (readonly)
Returns the value of attribute name_public.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def name_public @name_public end |
#no_vods ⇒ Object (readonly)
Returns the value of attribute no_vods.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def no_vods @no_vods end |
#published ⇒ Object (readonly)
Returns the value of attribute published.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def published @published end |
#season ⇒ Object (readonly)
Returns the value of attribute season.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def season @season end |
#winner ⇒ Object (readonly)
Returns the value of attribute winner.
3 4 5 |
# File 'lib/lolesports-api/tournament.rb', line 3 def winner @winner end |
Class Method Details
.find(tournament_id) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 |
Instance Method Details
#find_matches ⇒ Object
36 37 38 39 40 41 42 43 |
# 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 |