Class: Wuclan::Twitter::Scrape::TwitterStreamRequest
- Inherits:
-
Struct
- Object
- Struct
- Wuclan::Twitter::Scrape::TwitterStreamRequest
- Includes:
- Monkeyshines::RawJsonContents
- Defined in:
- lib/wuclan/twitter/scrape/twitter_stream_request.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
Instance Method Summary collapse
-
#healthy? ⇒ Boolean
Extracted JSON should be an array.
-
#parse(*args, &block) ⇒ Object
unpacks the raw API response, yielding all the interesting objects and relationships within.
- #parsed_as_delete_tweet(*args, &block) ⇒ Object
-
#parsed_as_tweet(*args, &block) ⇒ Object
Extract user and tweet.
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents
5 6 7 |
# File 'lib/wuclan/twitter/scrape/twitter_stream_request.rb', line 5 def contents @contents end |
Instance Method Details
#healthy? ⇒ Boolean
Extracted JSON should be an array
13 14 15 |
# File 'lib/wuclan/twitter/scrape/twitter_stream_request.rb', line 13 def healthy?() parsed_contents && parsed_contents.is_a?(Hash) end |
#parse(*args, &block) ⇒ Object
unpacks the raw API response, yielding all the interesting objects and relationships within.
34 35 36 37 38 39 |
# File 'lib/wuclan/twitter/scrape/twitter_stream_request.rb', line 34 def parse *args, &block return unless healthy? return parsed_as_delete_tweet(*args, &block) if JsonDeleteTweet.parses?(contents) # else parsed_as_tweet(*args, &block) end |
#parsed_as_delete_tweet(*args, &block) ⇒ Object
17 18 19 20 21 |
# File 'lib/wuclan/twitter/scrape/twitter_stream_request.rb', line 17 def parsed_as_delete_tweet *args, &block p parsed_contents json_obj = JsonDeleteTweet.new(parsed_contents) json_obj.each(&block) end |
#parsed_as_tweet(*args, &block) ⇒ Object
Extract user and tweet
24 25 26 27 28 |
# File 'lib/wuclan/twitter/scrape/twitter_stream_request.rb', line 24 def parsed_as_tweet *args, &block json_obj = JsonTweetWithUser.new( parsed_contents, 'scraped_at' => parsed_contents['created_at']) json_obj.each(&block) end |