Class: MLB::Linescore

Inherits:
Shale::Mapper
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_inningInteger

Returns the current inning number

Examples:

linescore.current_inning #=> 9

Returns:

  • (Integer)

    the current inning



18
# File 'lib/mlb/linescore.rb', line 18

attribute :current_inning, Shale::Type::Integer

#current_inning_ordinalString

Returns the current inning ordinal

Examples:

linescore.current_inning_ordinal #=> "9th"

Returns:

  • (String)

    the current inning ordinal



26
# File 'lib/mlb/linescore.rb', line 26

attribute :current_inning_ordinal, Shale::Type::String

#inning_halfString

Returns the inning half

Examples:

linescore.inning_half #=> "Bottom"

Returns:

  • (String)

    the inning half



42
# File 'lib/mlb/linescore.rb', line 42

attribute :inning_half, Shale::Type::String

#inning_stateString

Returns the inning state (Top/Middle/Bottom/End)

Examples:

linescore.inning_state #=> "Bottom"

Returns:

  • (String)

    the inning state



34
# File 'lib/mlb/linescore.rb', line 34

attribute :inning_state, Shale::Type::String

#inningsArray<InningScore>

Returns the inning-by-inning scores

Examples:

linescore.innings #=> [#<MLB::InningScore>, ...]

Returns:



66
# File 'lib/mlb/linescore.rb', line 66

attribute :innings, InningScore, collection: true

#is_top_inningBoolean

Returns whether it’s the top of the inning

Examples:

linescore.top_inning? #=> false

Returns:

  • (Boolean)

    whether it’s the top of the inning



50
# File 'lib/mlb/linescore.rb', line 50

attribute :is_top_inning, Shale::Type::Boolean

#scheduled_inningsInteger

Returns the number of scheduled innings

Examples:

linescore.scheduled_innings #=> 9

Returns:

  • (Integer)

    the scheduled innings



58
# File 'lib/mlb/linescore.rb', line 58

attribute :scheduled_innings, Shale::Type::Integer

#teamsLinescoreTeams

Returns the team totals

Examples:

linescore.teams #=> #<MLB::LinescoreTeams>

Returns:



74
# File 'lib/mlb/linescore.rb', line 74

attribute :teams, LinescoreTeams

Class Method Details

.find(game:) ⇒ Linescore

Retrieves the linescore for a game

Examples:

Get linescore for a game

MLB::Linescore.find(game: 745726)

Parameters:

Returns:



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

Examples:

linescore.bottom? #=> false

Returns:

  • (Boolean)

    whether it’s the bottom of the inning



108
# File 'lib/mlb/linescore.rb', line 108

def bottom? = inning_state.eql?(INNING_BOTTOM)

#eighteenth?Boolean

Returns whether it’s the 18th inning

Examples:

linescore.eighteenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.eighth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.eleventh? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.fifteenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.fifth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.first? #=> true

Returns:

  • (Boolean)

    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

Examples:

linescore.fourteenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.fourth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.middle? #=> false

Returns:

  • (Boolean)

    whether it’s the middle of the inning



100
# File 'lib/mlb/linescore.rb', line 100

def middle? = inning_state.eql?(INNING_MIDDLE)

#nineteenth?Boolean

Returns whether it’s the 19th inning

Examples:

linescore.nineteenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.ninth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.second? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.seventeenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.seventh? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.sixteenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.sixth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.tenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.third? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.thirteenth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.top? #=> true

Returns:

  • (Boolean)

    whether it’s the top of the inning



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

Examples:

linescore.top_inning? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twelfth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twentieth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twenty_fifth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twenty_first? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twenty_fourth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twenty_second? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twenty_sixth? #=> false

Returns:

  • (Boolean)

    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

Examples:

linescore.twenty_third? #=> false

Returns:

  • (Boolean)

    whether it’s the 23rd inning



292
# File 'lib/mlb/linescore.rb', line 292

def twenty_third? = current_inning.eql?(23)