class AhlScraper::BirthdateHelper
Attributes
birthdate[R]
Public Class Methods
new(birthdate)
click to toggle source
# File lib/ahl_scraper/helpers/birthdate_helper.rb, line 9 def initialize(birthdate) @birthdate = Date.parse(birthdate) end
Public Instance Methods
age_on_date(date, round: 2)
click to toggle source
# File lib/ahl_scraper/helpers/birthdate_helper.rb, line 23 def age_on_date(date, round: 2) ((Date.parse(date).to_datetime - birthdate.to_datetime).to_i / BigDecimal("365")).round(round) end
current_age(round: 2)
click to toggle source
# File lib/ahl_scraper/helpers/birthdate_helper.rb, line 19 def current_age(round: 2) ((Time.now.utc.to_datetime - birthdate.to_datetime).to_i / BigDecimal("365")).round(round) end
draft_year()
click to toggle source
# File lib/ahl_scraper/helpers/birthdate_helper.rb, line 13 def draft_year return (birthdate + (19 * 365)).year if (birthdate.month == 9 && birthdate.day > 15) || birthdate.month > 9 (birthdate + (18 * 365)).year end