Sha256: a3d4a9a65232c49972787411d577f5e17cc6a3a115cdf67b706ba14d2d5901dd
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module AhlScraper class Player < Resource def initialize(raw_data) @raw_data = raw_data end def id @id ||= @raw_data.dig(:info, :playerId).to_i end def name @name ||= "#{first_name} #{last_name}" end def first_name @first_name ||= @raw_data.dig(:info, :firstName) end def last_name @last_name ||= @raw_data.dig(:info, :lastName) end def shoots @shoots ||= @raw_data.dig(:info, :shoots) end def catches @catches ||= @raw_data.dig(:info, :catches) end def birthplace @birthplace ||= @raw_data.dig(:info, :birthPlace)&.strip end def height @height ||= @raw_data.dig(:info, :height_hyphenated) end def birthdate @birthdate ||= valid_birthdate? ? @raw_data.dig(:info, :birthDate) : nil end def draft_year @draft_year ||= valid_birthdate? ? BirthdateHelper.new(birthdate).draft_year : nil end def current_age @current_age ||= valid_birthdate? ? BirthdateHelper.new(birthdate).current_age : nil end def jersey_number @jersey_number ||= @raw_data.dig(:info, :jerseyNumber).to_i end def position @position ||= @raw_data.dig(:info, :position) end def weight @weight ||= @raw_data.dig(:info, :weight).to_i end private def valid_birthdate? @valid_birthdate ||= !@raw_data.dig(:info, :birthDate).empty? && @raw_data.dig(:info, :birthDate) != "0000-00-00" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ahl_scraper-0.1.1 | lib/ahl_scraper/resources/player.rb |