Class: Weeter::TweetItem
- Inherits:
-
Object
- Object
- Weeter::TweetItem
- Defined in:
- lib/weeter/tweet_item.rb
Instance Method Summary collapse
- #[](val) ⇒ Object
- #deletion? ⇒ Boolean
- #disconnect_notice? ⇒ Boolean
-
#initialize(tweet_hash) ⇒ TweetItem
constructor
A new instance of TweetItem.
- #limit_notice? ⇒ Boolean
- #limiting_facets ⇒ Object
- #missed_tweets_count ⇒ Object
- #publishable? ⇒ Boolean
- #reply? ⇒ Boolean
- #retweeted? ⇒ Boolean
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(tweet_hash) ⇒ TweetItem
Returns a new instance of TweetItem.
6 7 8 |
# File 'lib/weeter/tweet_item.rb', line 6 def initialize(tweet_hash) @tweet_hash = tweet_hash end |
Instance Method Details
#[](val) ⇒ Object
39 40 41 |
# File 'lib/weeter/tweet_item.rb', line 39 def [](val) @tweet_hash[val] end |
#deletion? ⇒ Boolean
10 11 12 |
# File 'lib/weeter/tweet_item.rb', line 10 def deletion? !@tweet_hash['delete'].nil? end |
#disconnect_notice? ⇒ Boolean
26 27 28 |
# File 'lib/weeter/tweet_item.rb', line 26 def disconnect_notice? !@tweet_hash['disconnect'].nil? end |
#limit_notice? ⇒ Boolean
30 31 32 |
# File 'lib/weeter/tweet_item.rb', line 30 def limit_notice? !@tweet_hash['limit'].nil? end |
#limiting_facets ⇒ Object
51 52 53 54 55 |
# File 'lib/weeter/tweet_item.rb', line 51 def limiting_facets self['entities']['hashtags'].map do |tag| tag['text'].downcase.chomp end end |
#missed_tweets_count ⇒ Object
34 35 36 37 |
# File 'lib/weeter/tweet_item.rb', line 34 def missed_tweets_count return nil unless limit_notice? @tweet_hash['limit']['track'] end |
#publishable? ⇒ Boolean
22 23 24 |
# File 'lib/weeter/tweet_item.rb', line 22 def publishable? !retweeted? && !reply? && !disconnect_notice? && !limit_notice? end |
#reply? ⇒ Boolean
18 19 20 |
# File 'lib/weeter/tweet_item.rb', line 18 def reply? !@tweet_hash['in_reply_to_user_id_str'].nil? || @tweet_hash['text'] =~ /^@/ end |
#retweeted? ⇒ Boolean
14 15 16 |
# File 'lib/weeter/tweet_item.rb', line 14 def retweeted? !@tweet_hash['retweeted_status'].nil? || @tweet_hash['text'] =~ /^RT @/i end |
#to_hash ⇒ Object
47 48 49 |
# File 'lib/weeter/tweet_item.rb', line 47 def to_hash @tweet_hash end |
#to_json ⇒ Object
43 44 45 |
# File 'lib/weeter/tweet_item.rb', line 43 def to_json MultiJson.encode(@tweet_hash) end |