Class: NbaDrilldown::Player
- Inherits:
-
Object
- Object
- NbaDrilldown::Player
- Defined in:
- lib/nba_drilldown/player.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#conference ⇒ Object
Returns the value of attribute conference.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#position ⇒ Object
Returns the value of attribute position.
-
#team ⇒ Object
Returns the value of attribute team.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_player_info ⇒ Object
-
#initialize ⇒ Player
constructor
A new instance of Player.
Constructor Details
#initialize ⇒ Player
Returns a new instance of Player.
6 7 8 |
# File 'lib/nba_drilldown/player.rb', line 6 def initialize end |
Instance Attribute Details
#conference ⇒ Object
Returns the value of attribute conference.
2 3 4 |
# File 'lib/nba_drilldown/player.rb', line 2 def conference @conference end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/nba_drilldown/player.rb', line 2 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
2 3 4 |
# File 'lib/nba_drilldown/player.rb', line 2 def number @number end |
#position ⇒ Object
Returns the value of attribute position.
2 3 4 |
# File 'lib/nba_drilldown/player.rb', line 2 def position @position end |
#team ⇒ Object
Returns the value of attribute team.
2 3 4 |
# File 'lib/nba_drilldown/player.rb', line 2 def team @team end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/nba_drilldown/player.rb', line 2 def url @url end |
Class Method Details
.create_from_data(player) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nba_drilldown/player.rb', line 11 def self.create_from_data(player) #doc.search("td.sortcell a").each do |player| new_player = NbaDrilldown::Player.new new_player.name = player.text new_player.url = player['href'] @@all << new_player new_player end |
.list_players ⇒ Object
36 37 38 39 40 |
# File 'lib/nba_drilldown/player.rb', line 36 def self.list_players @@all.each do |player| puts player.name end end |
Instance Method Details
#add_player_info ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/nba_drilldown/player.rb', line 26 def add_player_info doc = Nokogiri::HTML(open(self.url)) self.number = doc.search("ul.general-info li").first.text.match(/\d+/) self.position = doc.search("ul.general-info li").first.text.match(/[A-Z]+/) end |