Class: MLB::HomeRunDerby

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/mlb/home_run_derby.rb

Overview

Represents home run derby data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#infoDerbyInfo

Returns the derby info

Examples:

derby.info #=> #<MLB::DerbyInfo>


255
# File 'lib/mlb/home_run_derby.rb', line 255

attribute :info, DerbyInfo

#roundsArray<DerbyRound>

Returns the rounds

Examples:

derby.rounds #=> [#<MLB::DerbyRound>, ...]


263
# File 'lib/mlb/home_run_derby.rb', line 263

attribute :rounds, DerbyRound, collection: true

Class Method Details

.find(game:) ⇒ HomeRunDerby

Retrieves home run derby data for a game

Examples:

Get derby data for a game

MLB::HomeRunDerby.find(game: 511101)

Get derby data using a ScheduledGame object

MLB::HomeRunDerby.find(game: scheduled_game)


279
280
281
282
283
# File 'lib/mlb/home_run_derby.rb', line 279

def self.find(game:)
  game_pk = game.respond_to?(:game_pk) ? game.game_pk : game
  response = CLIENT.get("homeRunDerby/#{game_pk}")
  from_json(response)
end