Class: Weeter::TweetItem

Inherits:
Object
  • Object
show all
Defined in:
lib/weeter/tweet_item.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


10
11
12
# File 'lib/weeter/tweet_item.rb', line 10

def deletion?
  !@tweet_hash['delete'].nil?
end

#disconnect_notice?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/weeter/tweet_item.rb', line 26

def disconnect_notice?
  !@tweet_hash['disconnect'].nil?
end

#limit_notice?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/weeter/tweet_item.rb', line 30

def limit_notice?
  !@tweet_hash['limit'].nil?
end

#limiting_facetsObject



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_countObject



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

Returns:

  • (Boolean)


22
23
24
# File 'lib/weeter/tweet_item.rb', line 22

def publishable?
  !retweeted? && !reply? && !disconnect_notice? && !limit_notice?
end

#reply?Boolean

Returns:

  • (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

Returns:

  • (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_hashObject



47
48
49
# File 'lib/weeter/tweet_item.rb', line 47

def to_hash
  @tweet_hash
end

#to_jsonObject



43
44
45
# File 'lib/weeter/tweet_item.rb', line 43

def to_json
  MultiJson.encode(@tweet_hash)
end