Class: BadPigeon::ListTimeline

Inherits:
Object
  • Object
show all
Includes:
Assertions
Defined in:
lib/bad_pigeon/timelines/list_timeline.rb

Overview

Represents a timeline response for a list timeline.

A timeline includes one or more “instructions” (TimelineInstruction), and usually in particular a “TimelineAddEntries” instruction which provides one or more entries containing tweets.

Constant Summary collapse

EXPECTED_INSTRUCTIONS =
[TimelineInstruction::Type::ADD_ENTRIES]

Instance Method Summary collapse

Methods included from Assertions

extended, included

Constructor Details

#initialize(json) ⇒ ListTimeline

Returns a new instance of ListTimeline.



16
17
18
# File 'lib/bad_pigeon/timelines/list_timeline.rb', line 16

def initialize(json)
  @json = json
end

Instance Method Details

#instructionsObject



20
21
22
23
24
25
26
# File 'lib/bad_pigeon/timelines/list_timeline.rb', line 20

def instructions
  @instructions ||= begin
    list = @json['data']['list']['tweets_timeline']['timeline']['instructions']
    assert { list.all? { |i| EXPECTED_INSTRUCTIONS.include?(i['type']) }}
    list.map { |j| TimelineInstruction.new(j, self.class) }
  end
end