Sha256: 92720548b22d9097b059e30c83880dc9a321e91580a2cf5d09d7e882bd8b16f2

Contents?: true

Size: 726 Bytes

Versions: 7

Compression:

Stored size: 726 Bytes

Contents

module Tw
  class Tweet
    attr_reader :id, :user, :text, :time, :fav_count, :rt_count

    def initialize(opts)
      @id = opts[:id]
      @user = opts[:user]
      @text = opts[:text]
      @time = opts[:time].getlocal
      @fav_count = opts[:fav_count]
      @rt_count = opts[:rt_count]
    end

    def to_json(*a)
      {
        :id => @id,
        :user => @user,
        :text => @text,
        :time => @time,
        :fav_count => @fav_count,
        :rt_count => @rt_count
      }.to_json(*a)
    end

    def url
      "https://twitter.com/#{user}/status/#{id}"
    end

    def to_s
      "@#{user} #{text} - #{time} #{url}"
    end

    def format(fmt)
      self.instance_eval "\"#{fmt}\""
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tw-1.3.1 lib/tw/client/tweet.rb
tw-1.3.0 lib/tw/client/tweet.rb
tw-1.2.1 lib/tw/client/tweet.rb
tw-1.2.0 lib/tw/client/tweet.rb
tw-1.1.1 lib/tw/client/tweet.rb
tw-1.1.0 lib/tw/client/tweet.rb
tw-1.0.12 lib/tw/client/tweet.rb