class AhlScraper::RosterPlayer

Attributes

season_id[R]
team_id[R]

Public Class Methods

new(raw_data, team_id, season_id) click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 7
def initialize(raw_data, team_id, season_id)
  @raw_data = raw_data
  @team_id = team_id
  @season_id = season_id
end

Public Instance Methods

birthdate() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 33
def birthdate
  @birthdate ||= @raw_data.dig(:bio, :row, :birthdate)
end
birthplace() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 25
def birthplace
  @birthplace ||= @raw_data.dig(:bio, :row, :birthplace)
end
current_age() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 41
def current_age
  @current_age ||= valid_birthdate? ? birthdate_object.current_age : nil
end
draft_year() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 37
def draft_year
  @draft_year ||= valid_birthdate? ? birthdate_object.draft_year : nil
end
handedness() click to toggle source
# 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
height() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 29
def height
  @height ||= @raw_data.dig(:bio, :row, :height_hyphenated)
end
id() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 13
def id
  @id ||= @raw_data.dig(:bio, :row, :player_id).to_i
end
jersey_number() click to toggle source
# 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
name() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 17
def name
  @name ||= @raw_data.dig(:bio, :row, :name)
end
position() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 49
def position
  @position ||= @raw_data.dig(:bio, :row, :position)
end
rookie?() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 57
def rookie?
  @rookie ||= @raw_data.dig(:stats, :prop, :rookie, :rookie) == "1"
end
weight() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 53
def weight
  @weight ||= @raw_data.dig(:bio, :row, :w).to_i
end

Private Instance Methods

birthdate_object() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 63
def birthdate_object
  @birthdate_object ||= BirthdateHelper.new(birthdate)
end
valid_birthdate?() click to toggle source
# File lib/ahl_scraper/resources/roster_player.rb, line 67
def valid_birthdate?
  @valid_birthdate ||= !@raw_data.dig(:bio, :row, :birthdate).empty? && @raw_data.dig(:bio, :row, :birthdate) != "0000-00-00"
end