Class: CliEplTable::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/cli_epl_table/team.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Team

init all teams with corresponding attributes from the scraped data



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cli_epl_table/team.rb', line 11

def initialize(data)
  @position = data.css("span.value").text
  @name = data.css("td.team span.long").text
  @points = data.css("td.points").text
  @games_played = data.css("td")[3].text
  @games_won = data.css("td")[4].text
  @games_drawn = data.css("td")[5].text
  @games_lost = data.css("td")[6].text
  @goals_for = data.css("td")[7].text
  @goals_against = data.css("td")[8].text
  @goal_differential = data.css("td")[9].text.strip
  @@all << self
end

Instance Attribute Details

#games_drawnObject

Returns the value of attribute games_drawn.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def games_drawn
  @games_drawn
end

#games_lostObject

Returns the value of attribute games_lost.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def games_lost
  @games_lost
end

#games_playedObject

Returns the value of attribute games_played.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def games_played
  @games_played
end

#games_wonObject

Returns the value of attribute games_won.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def games_won
  @games_won
end

#goal_differentialObject

Returns the value of attribute goal_differential.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def goal_differential
  @goal_differential
end

#goals_againstObject

Returns the value of attribute goals_against.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def goals_against
  @goals_against
end

#goals_forObject

Returns the value of attribute goals_for.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def goals_for
  @goals_for
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def name
  @name
end

#pointsObject

Returns the value of attribute points.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def points
  @points
end

#positionObject

Returns the value of attribute position.



2
3
4
# File 'lib/cli_epl_table/team.rb', line 2

def position
  @position
end

Class Method Details

.allObject

define all



6
7
8
# File 'lib/cli_epl_table/team.rb', line 6

def self.all
  @@all
end