Class: MLB::Linescore
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Linescore
- Defined in:
- lib/mlb/linescore.rb
Overview
Represents a game’s linescore
Constant Summary collapse
- INNING_TOP =
"Top".freeze
- INNING_MIDDLE =
"Middle".freeze
- INNING_BOTTOM =
"Bottom".freeze
Instance Attribute Summary collapse
-
#current_inning ⇒ Integer
Returns the current inning number.
-
#current_inning_ordinal ⇒ String
Returns the current inning ordinal.
-
#inning_half ⇒ String
Returns the inning half.
-
#inning_state ⇒ String
Returns the inning state (Top/Middle/Bottom/End).
-
#innings ⇒ Array<InningScore>
Returns the inning-by-inning scores.
-
#is_top_inning ⇒ Boolean
Returns whether it’s the top of the inning.
-
#scheduled_innings ⇒ Integer
Returns the number of scheduled innings.
-
#teams ⇒ LinescoreTeams
Returns the team totals.
Class Method Summary collapse
-
.find(game:) ⇒ Linescore
Retrieves the linescore for a game.
Instance Method Summary collapse
-
#bottom? ⇒ Boolean
Returns whether the inning state is bottom.
-
#eighteenth? ⇒ Boolean
Returns whether it’s the 18th inning.
-
#eighth? ⇒ Boolean
Returns whether it’s the 8th inning.
-
#eleventh? ⇒ Boolean
Returns whether it’s the 11th inning.
-
#fifteenth? ⇒ Boolean
Returns whether it’s the 15th inning.
-
#fifth? ⇒ Boolean
Returns whether it’s the 5th inning.
-
#first? ⇒ Boolean
Returns whether it’s the 1st inning.
-
#fourteenth? ⇒ Boolean
Returns whether it’s the 14th inning.
-
#fourth? ⇒ Boolean
Returns whether it’s the 4th inning.
-
#middle? ⇒ Boolean
Returns whether the inning state is middle.
-
#nineteenth? ⇒ Boolean
Returns whether it’s the 19th inning.
-
#ninth? ⇒ Boolean
Returns whether it’s the 9th inning.
-
#second? ⇒ Boolean
Returns whether it’s the 2nd inning.
-
#seventeenth? ⇒ Boolean
Returns whether it’s the 17th inning.
-
#seventh? ⇒ Boolean
Returns whether it’s the 7th inning.
-
#sixteenth? ⇒ Boolean
Returns whether it’s the 16th inning.
-
#sixth? ⇒ Boolean
Returns whether it’s the 6th inning.
-
#tenth? ⇒ Boolean
Returns whether it’s the 10th inning.
-
#third? ⇒ Boolean
Returns whether it’s the 3rd inning.
-
#thirteenth? ⇒ Boolean
Returns whether it’s the 13th inning.
-
#top? ⇒ Boolean
Returns whether the inning state is top.
-
#top_inning? ⇒ Boolean
Returns whether it’s the top of the inning.
-
#twelfth? ⇒ Boolean
Returns whether it’s the 12th inning.
-
#twentieth? ⇒ Boolean
Returns whether it’s the 20th inning.
-
#twenty_fifth? ⇒ Boolean
Returns whether it’s the 25th inning.
-
#twenty_first? ⇒ Boolean
Returns whether it’s the 21st inning.
-
#twenty_fourth? ⇒ Boolean
Returns whether it’s the 24th inning.
-
#twenty_second? ⇒ Boolean
Returns whether it’s the 22nd inning.
-
#twenty_sixth? ⇒ Boolean
Returns whether it’s the 26th inning.
-
#twenty_third? ⇒ Boolean
Returns whether it’s the 23rd inning.
Instance Attribute Details
#current_inning ⇒ Integer
Returns the current inning number
18 |
# File 'lib/mlb/linescore.rb', line 18 attribute :current_inning, Shale::Type::Integer |
#current_inning_ordinal ⇒ String
Returns the current inning ordinal
26 |
# File 'lib/mlb/linescore.rb', line 26 attribute :current_inning_ordinal, Shale::Type::String |
#inning_half ⇒ String
Returns the inning half
42 |
# File 'lib/mlb/linescore.rb', line 42 attribute :inning_half, Shale::Type::String |
#inning_state ⇒ String
Returns the inning state (Top/Middle/Bottom/End)
34 |
# File 'lib/mlb/linescore.rb', line 34 attribute :inning_state, Shale::Type::String |
#innings ⇒ Array<InningScore>
Returns the inning-by-inning scores
66 |
# File 'lib/mlb/linescore.rb', line 66 attribute :innings, InningScore, collection: true |
#is_top_inning ⇒ Boolean
Returns whether it’s the top of the inning
50 |
# File 'lib/mlb/linescore.rb', line 50 attribute :is_top_inning, Shale::Type::Boolean |
#scheduled_innings ⇒ Integer
Returns the number of scheduled innings
58 |
# File 'lib/mlb/linescore.rb', line 58 attribute :scheduled_innings, Shale::Type::Integer |
#teams ⇒ LinescoreTeams
Returns the team totals
74 |
# File 'lib/mlb/linescore.rb', line 74 attribute :teams, LinescoreTeams |
Class Method Details
.find(game:) ⇒ Linescore
Retrieves the linescore for a game
336 337 338 339 340 |
# File 'lib/mlb/linescore.rb', line 336 def self.find(game:) game_pk = game.respond_to?(:game_pk) ? game.game_pk : game response = CLIENT.get("game/#{game_pk}/linescore") from_json(response) end |
Instance Method Details
#bottom? ⇒ Boolean
Returns whether the inning state is bottom
108 |
# File 'lib/mlb/linescore.rb', line 108 def bottom? = inning_state.eql?(INNING_BOTTOM) |
#eighteenth? ⇒ Boolean
Returns whether it’s the 18th inning
252 |
# File 'lib/mlb/linescore.rb', line 252 def eighteenth? = current_inning.eql?(18) |
#eighth? ⇒ Boolean
Returns whether it’s the 8th inning
172 |
# File 'lib/mlb/linescore.rb', line 172 def eighth? = current_inning.eql?(8) |
#eleventh? ⇒ Boolean
Returns whether it’s the 11th inning
196 |
# File 'lib/mlb/linescore.rb', line 196 def eleventh? = current_inning.eql?(11) |
#fifteenth? ⇒ Boolean
Returns whether it’s the 15th inning
228 |
# File 'lib/mlb/linescore.rb', line 228 def fifteenth? = current_inning.eql?(15) |
#fifth? ⇒ Boolean
Returns whether it’s the 5th inning
148 |
# File 'lib/mlb/linescore.rb', line 148 def fifth? = current_inning.eql?(5) |
#first? ⇒ Boolean
Returns whether it’s the 1st inning
116 |
# File 'lib/mlb/linescore.rb', line 116 def first? = current_inning.eql?(1) |
#fourteenth? ⇒ Boolean
Returns whether it’s the 14th inning
220 |
# File 'lib/mlb/linescore.rb', line 220 def fourteenth? = current_inning.eql?(14) |
#fourth? ⇒ Boolean
Returns whether it’s the 4th inning
140 |
# File 'lib/mlb/linescore.rb', line 140 def fourth? = current_inning.eql?(4) |
#middle? ⇒ Boolean
Returns whether the inning state is middle
100 |
# File 'lib/mlb/linescore.rb', line 100 def middle? = inning_state.eql?(INNING_MIDDLE) |
#nineteenth? ⇒ Boolean
Returns whether it’s the 19th inning
260 |
# File 'lib/mlb/linescore.rb', line 260 def nineteenth? = current_inning.eql?(19) |
#ninth? ⇒ Boolean
Returns whether it’s the 9th inning
180 |
# File 'lib/mlb/linescore.rb', line 180 def ninth? = current_inning.eql?(9) |
#second? ⇒ Boolean
Returns whether it’s the 2nd inning
124 |
# File 'lib/mlb/linescore.rb', line 124 def second? = current_inning.eql?(2) |
#seventeenth? ⇒ Boolean
Returns whether it’s the 17th inning
244 |
# File 'lib/mlb/linescore.rb', line 244 def seventeenth? = current_inning.eql?(17) |
#seventh? ⇒ Boolean
Returns whether it’s the 7th inning
164 |
# File 'lib/mlb/linescore.rb', line 164 def seventh? = current_inning.eql?(7) |
#sixteenth? ⇒ Boolean
Returns whether it’s the 16th inning
236 |
# File 'lib/mlb/linescore.rb', line 236 def sixteenth? = current_inning.eql?(16) |
#sixth? ⇒ Boolean
Returns whether it’s the 6th inning
156 |
# File 'lib/mlb/linescore.rb', line 156 def sixth? = current_inning.eql?(6) |
#tenth? ⇒ Boolean
Returns whether it’s the 10th inning
188 |
# File 'lib/mlb/linescore.rb', line 188 def tenth? = current_inning.eql?(10) |
#third? ⇒ Boolean
Returns whether it’s the 3rd inning
132 |
# File 'lib/mlb/linescore.rb', line 132 def third? = current_inning.eql?(3) |
#thirteenth? ⇒ Boolean
Returns whether it’s the 13th inning
212 |
# File 'lib/mlb/linescore.rb', line 212 def thirteenth? = current_inning.eql?(13) |
#top? ⇒ Boolean
Returns whether the inning state is top
92 |
# File 'lib/mlb/linescore.rb', line 92 def top? = inning_state.eql?(INNING_TOP) |
#top_inning? ⇒ Boolean
Returns whether it’s the top of the inning
82 83 84 |
# File 'lib/mlb/linescore.rb', line 82 def top_inning? is_top_inning end |
#twelfth? ⇒ Boolean
Returns whether it’s the 12th inning
204 |
# File 'lib/mlb/linescore.rb', line 204 def twelfth? = current_inning.eql?(12) |
#twentieth? ⇒ Boolean
Returns whether it’s the 20th inning
268 |
# File 'lib/mlb/linescore.rb', line 268 def twentieth? = current_inning.eql?(20) |
#twenty_fifth? ⇒ Boolean
Returns whether it’s the 25th inning
308 |
# File 'lib/mlb/linescore.rb', line 308 def twenty_fifth? = current_inning.eql?(25) |
#twenty_first? ⇒ Boolean
Returns whether it’s the 21st inning
276 |
# File 'lib/mlb/linescore.rb', line 276 def twenty_first? = current_inning.eql?(21) |
#twenty_fourth? ⇒ Boolean
Returns whether it’s the 24th inning
300 |
# File 'lib/mlb/linescore.rb', line 300 def twenty_fourth? = current_inning.eql?(24) |
#twenty_second? ⇒ Boolean
Returns whether it’s the 22nd inning
284 |
# File 'lib/mlb/linescore.rb', line 284 def twenty_second? = current_inning.eql?(22) |
#twenty_sixth? ⇒ Boolean
Returns whether it’s the 26th inning
316 |
# File 'lib/mlb/linescore.rb', line 316 def twenty_sixth? = current_inning.eql?(26) |
#twenty_third? ⇒ Boolean
Returns whether it’s the 23rd inning
292 |
# File 'lib/mlb/linescore.rb', line 292 def twenty_third? = current_inning.eql?(23) |