Class: BadPigeon::UserTimeline
- Inherits:
-
Object
- Object
- BadPigeon::UserTimeline
- Includes:
- Assertions
- Defined in:
- lib/bad_pigeon/timelines/user_timeline.rb
Overview
Represents a timeline response for a timeline of user’s posts as seen on their profile page.
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, TimelineInstruction::Type::CLEAR_CACHE, TimelineInstruction::Type::PIN_ENTRY ]
Instance Method Summary collapse
-
#initialize(json) ⇒ UserTimeline
constructor
A new instance of UserTimeline.
- #instructions ⇒ Object
Methods included from Assertions
Constructor Details
#initialize(json) ⇒ UserTimeline
Returns a new instance of UserTimeline.
20 21 22 |
# File 'lib/bad_pigeon/timelines/user_timeline.rb', line 20 def initialize(json) @json = json end |
Instance Method Details
#instructions ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/bad_pigeon/timelines/user_timeline.rb', line 24 def instructions @instructions ||= begin list = @json['data']['user']['result']['timeline_v2']['timeline']['instructions'] assert { list.all? { |i| EXPECTED_INSTRUCTIONS.include?(i['type']) }} list.map { |j| TimelineInstruction.new(j, self.class) } end end |