Class: AhlScraper::Player
Instance Method Summary
collapse
Methods inherited from Resource
#[], #each, #inspect, #keys, #to_json, #values
Constructor Details
#initialize(raw_data, opts = {}) ⇒ Player
Returns a new instance of Player.
5
6
7
|
# File 'lib/ahl_scraper/resources/player.rb', line 5
def initialize(raw_data, opts = {})
super(raw_data, opts)
end
|
Instance Method Details
#birthdate ⇒ Object
37
38
39
|
# File 'lib/ahl_scraper/resources/player.rb', line 37
def birthdate
@birthdate ||= valid_birthdate? ? @raw_data.dig(:info, :birthDate) : nil
end
|
#birthplace ⇒ Object
29
30
31
|
# File 'lib/ahl_scraper/resources/player.rb', line 29
def birthplace
@birthplace ||= @raw_data.dig(:info, :birthPlace)&.strip
end
|
#current_age ⇒ Object
45
46
47
|
# File 'lib/ahl_scraper/resources/player.rb', line 45
def current_age
@current_age ||= valid_birthdate? ? BirthdateHelper.new(birthdate).current_age : nil
end
|
#draft_info ⇒ Object
61
62
63
|
# File 'lib/ahl_scraper/resources/player.rb', line 61
def draft_info
@draft_info ||= Players::DraftInfo.new(draft_data)
end
|
#draft_year ⇒ Object
41
42
43
|
# File 'lib/ahl_scraper/resources/player.rb', line 41
def draft_year
@draft_year ||= valid_birthdate? ? BirthdateHelper.new(birthdate).draft_year : nil
end
|
#first_name ⇒ Object
17
18
19
|
# File 'lib/ahl_scraper/resources/player.rb', line 17
def first_name
@first_name ||= @raw_data.dig(:info, :firstName)
end
|
#handedness ⇒ Object
25
26
27
|
# File 'lib/ahl_scraper/resources/player.rb', line 25
def handedness
@handedness ||= position == "G" ? @raw_data.dig(:info, :catches) : @raw_data.dig(:info, :shoots)
end
|
#height ⇒ Object
33
34
35
|
# File 'lib/ahl_scraper/resources/player.rb', line 33
def height
@height ||= @raw_data.dig(:info, :height_hyphenated)
end
|
#id ⇒ Object
9
10
11
|
# File 'lib/ahl_scraper/resources/player.rb', line 9
def id
@id ||= @raw_data.dig(:info, :playerId).to_i
end
|
#jersey_number ⇒ Object
49
50
51
|
# File 'lib/ahl_scraper/resources/player.rb', line 49
def jersey_number
@jersey_number ||= @raw_data.dig(:info, :jerseyNumber).to_i
end
|
#last_name ⇒ Object
21
22
23
|
# File 'lib/ahl_scraper/resources/player.rb', line 21
def last_name
@last_name ||= @raw_data.dig(:info, :lastName)
end
|
#name ⇒ Object
13
14
15
|
# File 'lib/ahl_scraper/resources/player.rb', line 13
def name
@name ||= "#{first_name} #{last_name}"
end
|
#position ⇒ Object
53
54
55
|
# File 'lib/ahl_scraper/resources/player.rb', line 53
def position
@position ||= @raw_data.dig(:info, :position)
end
|
#weight ⇒ Object
57
58
59
|
# File 'lib/ahl_scraper/resources/player.rb', line 57
def weight
@weight ||= @raw_data.dig(:info, :weight).to_i
end
|