Sha256: 3e4e3ea5fe5c52a33566bc26e3f91a71a59533c9033a82ac802a83f231e465d5

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

require 'multi_json'

module Weeter

  class TweetItem
    def initialize(tweet_hash)
      @tweet_hash = tweet_hash
    end

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

    def retweeted?
      !@tweet_hash['retweeted_status'].nil? || @tweet_hash['text'] =~ /^RT @/i
    end

    def reply?
      !@tweet_hash['in_reply_to_user_id_str'].nil? || @tweet_hash['text'] =~ /^@/
    end

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

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

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

    def missed_tweets_count
      return nil unless limit_notice?
      @tweet_hash['limit']['track']
    end

    def [](val)
      @tweet_hash[val]
    end

    def to_json
      MultiJson.encode(@tweet_hash)
    end

    def to_hash
      @tweet_hash
    end

    def limiting_facets
      self['entities']['hashtags'].map do |tag|
        tag['text'].downcase.chomp
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
weeter-0.19.4 lib/weeter/tweet_item.rb
weeter-0.19.3 lib/weeter/tweet_item.rb
weeter-0.19.2 lib/weeter/tweet_item.rb
weeter-0.19.1 lib/weeter/tweet_item.rb
weeter-0.19.0 lib/weeter/tweet_item.rb
weeter-0.18.0 lib/weeter/tweet_item.rb
weeter-0.17.0 lib/weeter/tweet_item.rb
weeter-0.15.0 lib/weeter/tweet_item.rb
weeter-0.14.0 lib/weeter/tweet_item.rb
weeter-0.13.0 lib/weeter/twitter/tweet_item.rb