Class: LolesportsApi::Team

Inherits:
BaseApiObject show all
Defined in:
lib/lolesports-api/team.rb

Constant Summary collapse

API_URL =
'http://na.lolesports.com/api/team'

Constants inherited from BaseApiObject

BaseApiObject::SCHEDULE_URL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseApiObject

fail_by_status, #reload

Constructor Details

#initialize(attributes = {}) ⇒ Team

Returns a new instance of Team.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lolesports-api/team.rb', line 9

def initialize(attributes = {})
  @id = attributes['id'].to_i
  @acronym = attributes['acronym']
  @bio = attributes['bio']
  @logo_url = attributes['logoUrl']
  @name = attributes['name']
  @no_players = attributes['noPlayers']
  @profile_url = attributes['profileUrl']
  @roster = []
  @team_photo_url = attributes['teamPhotoUrl']
  @losses = attributes['losses']
  @wins = attributes['wins']
end

Instance Attribute Details

#acronymObject (readonly)

Returns the value of attribute acronym.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def acronym
  @acronym
end

#bioObject (readonly)

Returns the value of attribute bio.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def bio
  @bio
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def id
  @id
end

#logo_urlObject (readonly)

Returns the value of attribute logo_url.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def logo_url
  @logo_url
end

#lossesObject (readonly)

Returns the value of attribute losses.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def losses
  @losses
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def name
  @name
end

#no_playersObject (readonly)

Returns the value of attribute no_players.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def no_players
  @no_players
end

#profile_urlObject (readonly)

Returns the value of attribute profile_url.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def profile_url
  @profile_url
end

#rosterObject (readonly)

Returns the value of attribute roster.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def roster
  @roster
end

#team_photo_urlObject (readonly)

Returns the value of attribute team_photo_url.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def team_photo_url
  @team_photo_url
end

#winsObject (readonly)

Returns the value of attribute wins.



3
4
5
# File 'lib/lolesports-api/team.rb', line 3

def wins
  @wins
end

Class Method Details

.find(team_id) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/lolesports-api/team.rb', line 23

def self.find(team_id)
  super
  if @attributes['roster'].any?
    @attributes['roster'].each_value do |player|
      @base_object.roster << LolesportsApi::Player.new(player)
    end
  end
  @base_object
end