Class: MLB::GameContent

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

Overview

Represents the game content

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#highlightsHighlightsSection

Returns the highlights

Examples:

content.highlights #=> #<MLB::HighlightsSection>

Returns:



228
# File 'lib/mlb/game_content.rb', line 228

attribute :highlights, HighlightsSection

Returns the API link

Examples:

content.link #=> "/api/v1/game/745571/content"

Returns:

  • (String)

    the link



212
# File 'lib/mlb/game_content.rb', line 212

attribute :link, Shale::Type::String

#mediaGameContentMedia

Returns the media info

Examples:

content.media #=> #<MLB::GameContentMedia>

Returns:



220
# File 'lib/mlb/game_content.rb', line 220

attribute :media, GameContentMedia

Class Method Details

.find(game:) ⇒ GameContent

Retrieves the content for a game

Examples:

Get content for a game

MLB::GameContent.find(game: 745571)

Get content using a ScheduledGame object

MLB::GameContent.find(game: scheduled_game)

Parameters:

Returns:



245
246
247
248
249
# File 'lib/mlb/game_content.rb', line 245

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