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, data) ⇒ ColorFeed

Returns a new instance of ColorFeed.



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

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

  # If we need to nuke and start over, keep this piece
  @id = data['game_pk']
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#itemsObject



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

def items
  @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/#{@id}/feed/color")

  true
rescue Net::OpenTimeout
  false
end