Class: DaFace::Twitter::Tweet
- Inherits:
-
Object
- Object
- DaFace::Twitter::Tweet
- Includes:
- Utilities
- Defined in:
- lib/da_face/twitter/tweet.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#retweet ⇒ Object
readonly
Returns the value of attribute retweet.
-
#retweet_count ⇒ Object
readonly
Returns the value of attribute retweet_count.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #allowed_attributes ⇒ Object
- #id_str ⇒ Object
-
#initialize(data = {}) ⇒ Tweet
constructor
A new instance of Tweet.
- #normalize_attributes! ⇒ Object
- #retweet? ⇒ Boolean
Methods included from Utilities
#parse_json, #parse_timestamp, #parse_uri, #symbolize_keys
Constructor Details
#initialize(data = {}) ⇒ Tweet
Returns a new instance of Tweet.
9 10 11 12 13 14 15 16 17 |
# File 'lib/da_face/twitter/tweet.rb', line 9 def initialize data={} allowed_attributes.each do |attr| unless data[attr].nil? self.instance_variable_set("@#{attr}".to_sym, data[attr]) end end normalize_attributes! return self end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def id @id end |
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def lang @lang end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def links @links end |
#retweet ⇒ Object (readonly)
Returns the value of attribute retweet.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def retweet @retweet end |
#retweet_count ⇒ Object (readonly)
Returns the value of attribute retweet_count.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def retweet_count @retweet_count end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def source @source end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def text @text end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/da_face/twitter/tweet.rb', line 6 def user @user end |
Instance Method Details
#allowed_attributes ⇒ Object
37 38 39 40 |
# File 'lib/da_face/twitter/tweet.rb', line 37 def allowed_attributes [:id, :user, :created_at, :lang, :text, :source, :links, :retweet, :retweet_count] end |
#id_str ⇒ Object
27 28 29 |
# File 'lib/da_face/twitter/tweet.rb', line 27 def id_str @id.to_s end |
#normalize_attributes! ⇒ Object
31 32 33 34 35 |
# File 'lib/da_face/twitter/tweet.rb', line 31 def normalize_attributes! @created_at = (@created_at) if @created_at @links = parse_links(@links) if @links @id = @id.to_i if @id end |
#retweet? ⇒ Boolean
19 20 21 |
# File 'lib/da_face/twitter/tweet.rb', line 19 def retweet? @retweet || false end |