Class: MLBStatsAPI::ColorFeed

Inherits:
Base
  • Object
show all
Defined in:
lib/mlb_stats_api/color_feed.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#[], #dig

Constructor Details

#initialize(api, game_pk, data) ⇒ ColorFeed

Returns a new instance of ColorFeed.



7
8
9
10
11
# File 'lib/mlb_stats_api/color_feed.rb', line 7

def initialize(api, game_pk, data)
  @api = api
  @data = data
  @game_pk = game_pk
end

Instance Attribute Details

#game_pkObject (readonly)

Returns the value of attribute game_pk.



5
6
7
# File 'lib/mlb_stats_api/color_feed.rb', line 5

def game_pk
  @game_pk
end

Instance Method Details

#itemsObject



13
14
15
16
17
# File 'lib/mlb_stats_api/color_feed.rb', line 13

def items
  return [] unless @data

  @data['items']
end

#reload!Object Also known as: update!



19
20
21
22
23
24
25
# File 'lib/mlb_stats_api/color_feed.rb', line 19

def reload!
  @data = @api.get("/game/#{@game_pk}/feed/color")

  true
rescue Net::OpenTimeout
  false
end