Class: Tw::Tweet
- Inherits:
-
Object
- Object
- Tw::Tweet
- Defined in:
- lib/tw/client/tweet.rb
Instance Attribute Summary collapse
-
#fav_count ⇒ Object
readonly
Returns the value of attribute fav_count.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#rt_count ⇒ Object
readonly
Returns the value of attribute rt_count.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #format(fmt) ⇒ Object
-
#initialize(opts) ⇒ Tweet
constructor
A new instance of Tweet.
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
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_count ⇒ Object (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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/tw/client/tweet.rb', line 3 def id @id end |
#rt_count ⇒ Object (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 |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/tw/client/tweet.rb', line 3 def text @text end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/tw/client/tweet.rb', line 3 def time @time end |
#user ⇒ Object (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_s ⇒ Object
29 30 31 |
# File 'lib/tw/client/tweet.rb', line 29 def to_s "@#{user} #{text} - #{time} #{url}" end |
#url ⇒ Object
25 26 27 |
# File 'lib/tw/client/tweet.rb', line 25 def url "https://twitter.com/#{user}/status/#{id}" end |