Class: Tw::Tweet

Inherits:
Object
  • Object
show all
Defined in:
lib/tw/client/tweet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Tweet

Returns a new instance of Tweet.



5
6
7
8
9
10
11
12
# File 'lib/tw/client/tweet.rb', line 5

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

Instance Attribute Details

#fav_countObject (readonly)

Returns the value of attribute fav_count.



3
4
5
# File 'lib/tw/client/tweet.rb', line 3

def fav_count
  @fav_count
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/tw/client/tweet.rb', line 3

def id
  @id
end

#rt_countObject (readonly)

Returns the value of attribute rt_count.



3
4
5
# File 'lib/tw/client/tweet.rb', line 3

def rt_count
  @rt_count
end

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'lib/tw/client/tweet.rb', line 3

def text
  @text
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/tw/client/tweet.rb', line 3

def time
  @time
end

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/tw/client/tweet.rb', line 3

def user
  @user
end

Instance Method Details

#format(fmt) ⇒ Object



33
34
35
# File 'lib/tw/client/tweet.rb', line 33

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

#to_json(*a) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/tw/client/tweet.rb', line 14

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

#to_sObject



29
30
31
# File 'lib/tw/client/tweet.rb', line 29

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

#urlObject



25
26
27
# File 'lib/tw/client/tweet.rb', line 25

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