Class: NbaPlayer

Inherits:
Object
  • Object
show all
Includes:
NbaUrls
Defined in:
lib/espnscrape/NbaPlayer.rb

Overview

Read basic bio info from ESPN Player page

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NbaUrls

#boxScoreUrl, #checkSpecial, #formatTeamUrl, #getTid, #playerUrl, #seasonYearEnd, #seasonYears, #teamListUrl, #teamRosterUrl, #teamScheduleUrl

Constructor Details

#initialize(espn_player_id, file = '') ⇒ NbaPlayer

Read Player Data



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/espnscrape/NbaPlayer.rb', line 21

def initialize(espn_player_id, file = '')
  espn_player_id = espn_player_id.to_s
  if !espn_player_id.empty?
    url = playerUrl + espn_player_id
    doc = Nokogiri::HTML(open(url))
  else
    doc = Nokogiri::HTML(open(file)) rescue nil
  end
  return if doc.nil?

  readInfo(doc)
end

Instance Attribute Details

#ageInteger

Returns Age.

Returns:

  • (Integer)

    Age



10
11
12
# File 'lib/espnscrape/NbaPlayer.rb', line 10

def age
  @age
end

#collegeString

Returns College.

Returns:



12
13
14
# File 'lib/espnscrape/NbaPlayer.rb', line 12

def college
  @college
end

#h_ftInteger

Returns Height (ft).

Returns:

  • (Integer)

    Height (ft)



16
17
18
# File 'lib/espnscrape/NbaPlayer.rb', line 16

def h_ft
  @h_ft
end

#h_inInteger

Returns Height (in).

Returns:

  • (Integer)

    Height (in)



18
19
20
# File 'lib/espnscrape/NbaPlayer.rb', line 18

def h_in
  @h_in
end

#nameString

Returns Name.

Returns:



6
7
8
# File 'lib/espnscrape/NbaPlayer.rb', line 6

def name
  @name
end

#positionString

Returns Position.

Returns:



8
9
10
# File 'lib/espnscrape/NbaPlayer.rb', line 8

def position
  @position
end

#weightInteger

Returns Weight.

Returns:

  • (Integer)

    Weight



14
15
16
# File 'lib/espnscrape/NbaPlayer.rb', line 14

def weight
  @weight
end

Instance Method Details

#height_ftObject

alias for h_ft



35
36
37
# File 'lib/espnscrape/NbaPlayer.rb', line 35

def height_ft
  @h_ft
end

#height_inObject

alias for h_in



40
41
42
# File 'lib/espnscrape/NbaPlayer.rb', line 40

def height_in
  @h_in
end