Class: Sportradar::Nhl::Models::Period
- Inherits:
-
Object
- Object
- Sportradar::Nhl::Models::Period
- Defined in:
- lib/sportradar/nhl/models/period.rb
Instance Method Summary collapse
- #abbreviation ⇒ Object
- #events ⇒ Object
- #events_data ⇒ Object
- #game_id ⇒ Object
- #id ⇒ Object
-
#initialize(game_id:, attributes:) ⇒ Period
constructor
A new instance of Period.
- #number ⇒ Object
- #penalties ⇒ Object
- #plays ⇒ Object
- #scoring_plays ⇒ Object
- #sequence ⇒ Object
- #stoppages ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(game_id:, attributes:) ⇒ Period
Returns a new instance of Period.
5 6 7 8 9 |
# File 'lib/sportradar/nhl/models/period.rb', line 5 def initialize(game_id:, attributes:) @game_id = game_id @attributes = attributes build_events end |
Instance Method Details
#abbreviation ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sportradar/nhl/models/period.rb', line 15 def abbreviation case type when 'period' "#{number}P" when 'overtime' "#{number}OT" when 'shootout' 'SO' else "#{number}" end end |
#events ⇒ Object
48 49 50 |
# File 'lib/sportradar/nhl/models/period.rb', line 48 def events @events ||= [] end |
#events_data ⇒ Object
52 53 54 |
# File 'lib/sportradar/nhl/models/period.rb', line 52 def events_data @actions ||= @attributes.dig('events') || [] end |
#game_id ⇒ Object
28 29 30 |
# File 'lib/sportradar/nhl/models/period.rb', line 28 def game_id @game_id end |
#id ⇒ Object
32 33 34 |
# File 'lib/sportradar/nhl/models/period.rb', line 32 def id @id end |
#number ⇒ Object
36 37 38 |
# File 'lib/sportradar/nhl/models/period.rb', line 36 def number @attributes['number'] || 0 end |
#penalties ⇒ Object
56 57 58 |
# File 'lib/sportradar/nhl/models/period.rb', line 56 def penalties @penalties ||= [] end |
#plays ⇒ Object
60 61 62 |
# File 'lib/sportradar/nhl/models/period.rb', line 60 def plays @plays ||= [] end |
#scoring_plays ⇒ Object
64 65 66 |
# File 'lib/sportradar/nhl/models/period.rb', line 64 def scoring_plays @scoring_plays ||= [] end |
#sequence ⇒ Object
40 41 42 |
# File 'lib/sportradar/nhl/models/period.rb', line 40 def sequence @attributes['sequence'] || 0 end |
#stoppages ⇒ Object
68 69 70 |
# File 'lib/sportradar/nhl/models/period.rb', line 68 def stoppages @stoppages ||= [] end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/sportradar/nhl/models/period.rb', line 11 def to_s "#{type.titleize} #{number}" end |
#type ⇒ Object
44 45 46 |
# File 'lib/sportradar/nhl/models/period.rb', line 44 def type @attributes['type'] end |