Class: AhlScraper::RosterPlayer

Inherits:
Resource
  • Object
show all
Defined in:
lib/ahl_scraper/resources/roster_player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#[], #each, #inspect, #keys, #to_json, #values

Constructor Details

#initialize(raw_data, team_id, season_id) ⇒ RosterPlayer

Returns a new instance of RosterPlayer.



7
8
9
10
11
# File 'lib/ahl_scraper/resources/roster_player.rb', line 7

def initialize(raw_data, team_id, season_id)
  super(raw_data, {})
  @team_id = team_id
  @season_id = season_id
end

Instance Attribute Details

#season_idObject (readonly)

Returns the value of attribute season_id.



5
6
7
# File 'lib/ahl_scraper/resources/roster_player.rb', line 5

def season_id
  @season_id
end

#team_idObject (readonly)

Returns the value of attribute team_id.



5
6
7
# File 'lib/ahl_scraper/resources/roster_player.rb', line 5

def team_id
  @team_id
end

Instance Method Details

#birthdateObject



33
34
35
# File 'lib/ahl_scraper/resources/roster_player.rb', line 33

def birthdate
  @birthdate ||= @raw_data.dig(:bio, :row, :birthdate)
end

#birthplaceObject



25
26
27
# File 'lib/ahl_scraper/resources/roster_player.rb', line 25

def birthplace
  @birthplace ||= @raw_data.dig(:bio, :row, :birthplace)
end

#current_ageObject



41
42
43
# File 'lib/ahl_scraper/resources/roster_player.rb', line 41

def current_age
  @current_age ||= valid_birthdate? ? birthdate_object.current_age : nil
end

#draft_yearObject



37
38
39
# File 'lib/ahl_scraper/resources/roster_player.rb', line 37

def draft_year
  @draft_year ||= valid_birthdate? ? birthdate_object.draft_year : nil
end

#handednessObject



21
22
23
# File 'lib/ahl_scraper/resources/roster_player.rb', line 21

def handedness
  @handedness ||= position == "G" ? @raw_data.dig(:bio, :row, :catches) : @raw_data.dig(:bio, :row, :shoots)
end

#heightObject



29
30
31
# File 'lib/ahl_scraper/resources/roster_player.rb', line 29

def height
  @height ||= @raw_data.dig(:bio, :row, :height_hyphenated)
end

#idObject



13
14
15
# File 'lib/ahl_scraper/resources/roster_player.rb', line 13

def id
  @id ||= @raw_data.dig(:bio, :row, :player_id).to_i
end

#jersey_numberObject



45
46
47
# File 'lib/ahl_scraper/resources/roster_player.rb', line 45

def jersey_number
  @jersey_number ||= @raw_data.dig(:bio, :row, :tp_jersey_number).to_i
end

#nameObject



17
18
19
# File 'lib/ahl_scraper/resources/roster_player.rb', line 17

def name
  @name ||= @raw_data.dig(:bio, :row, :name)
end

#positionObject



49
50
51
# File 'lib/ahl_scraper/resources/roster_player.rb', line 49

def position
  @position ||= @raw_data.dig(:bio, :row, :position)
end

#rookie?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/ahl_scraper/resources/roster_player.rb', line 57

def rookie?
  @rookie ||= @raw_data.dig(:stats, :prop, :rookie, :rookie) == "1"
end

#weightObject



53
54
55
# File 'lib/ahl_scraper/resources/roster_player.rb', line 53

def weight
  @weight ||= @raw_data.dig(:bio, :row, :w).to_i
end