Class: AhlScraper::Games::PenaltyShot

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

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

This class inherits a constructor from AhlScraper::Resource

Instance Method Details

#game_time_elapsedObject



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

def game_time_elapsed
  @game_time_elapsed ||= period_time.to_elapsed
end

#goalieObject



20
21
22
23
24
25
26
27
28
# File 'lib/ahl_scraper/resources/games/penalty_shot.rb', line 20

def goalie
  @goalie ||= {
    id: @raw_data[:goalie][:id],
    first_name: @raw_data[:goalie][:firstName],
    last_name: @raw_data[:goalie][:lastName],
    jersey_number: @raw_data[:goalie][:jerseyNumber],
    position: @raw_data[:goalie][:position],
  }
end

#numberObject



6
7
8
# File 'lib/ahl_scraper/resources/games/penalty_shot.rb', line 6

def number
  @number ||= @opts[:number]
end

#periodObject



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

def period
  @period ||= @raw_data[:period][:id].to_i
end

#period_time_in_secondsObject



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

def period_time_in_seconds
  @period_time_in_seconds ||= period_time.to_sec
end

#scored?Boolean

Returns:

  • (Boolean)


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

def scored?
  @scored ||= @raw_data[:isGoal] == true
end

#scored_in_wordsObject



61
62
63
64
65
66
67
68
# File 'lib/ahl_scraper/resources/games/penalty_shot.rb', line 61

def scored_in_words
  @scored_in_words ||=
    if scored?
      "Scored"
    else
      "Missed"
    end
end

#shooterObject



10
11
12
13
14
15
16
17
18
# File 'lib/ahl_scraper/resources/games/penalty_shot.rb', line 10

def shooter
  @shooter ||= {
    id: @raw_data[:shooter][:id],
    first_name: @raw_data[:shooter][:firstName],
    last_name: @raw_data[:shooter][:lastName],
    jersey_number: @raw_data[:shooter][:jerseyNumber],
    position: @raw_data[:shooter][:position],
  }
end

#shooting_teamObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/ahl_scraper/resources/games/penalty_shot.rb', line 30

def shooting_team
  @shooting_team ||= {
    id: @raw_data[:shooter_team][:id],
    full_name: @raw_data[:shooter_team][:name],
    city: @raw_data[:shooter_team][:city],
    name: @raw_data[:shooter_team][:nickname],
    abbreviation: @raw_data[:shooter_team][:abbreviation],
    logo_url: @raw_data[:shooter_team][:logo],
  }
end

#timeObject



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

def time
  @time ||= @raw_data[:time]
end