Class: NbaDrilldown::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/nba_drilldown/player.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePlayer

Returns a new instance of Player.



6
7
8
# File 'lib/nba_drilldown/player.rb', line 6

def initialize

end

Instance Attribute Details

#conferenceObject

Returns the value of attribute conference.



2
3
4
# File 'lib/nba_drilldown/player.rb', line 2

def conference
  @conference
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/nba_drilldown/player.rb', line 2

def name
  @name
end

#numberObject

Returns the value of attribute number.



2
3
4
# File 'lib/nba_drilldown/player.rb', line 2

def number
  @number
end

#positionObject

Returns the value of attribute position.



2
3
4
# File 'lib/nba_drilldown/player.rb', line 2

def position
  @position
end

#teamObject

Returns the value of attribute team.



2
3
4
# File 'lib/nba_drilldown/player.rb', line 2

def team
  @team
end

#urlObject

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_playersObject



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_infoObject



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