Class: DaFace::Twitter::Tweet

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/da_face/twitter/tweet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_atObject (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

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/da_face/twitter/tweet.rb', line 6

def id
  @id
end

#langObject (readonly)

Returns the value of attribute lang.



6
7
8
# File 'lib/da_face/twitter/tweet.rb', line 6

def lang
  @lang
end

Returns the value of attribute links.



6
7
8
# File 'lib/da_face/twitter/tweet.rb', line 6

def links
  @links
end

#retweetObject (readonly)

Returns the value of attribute retweet.



6
7
8
# File 'lib/da_face/twitter/tweet.rb', line 6

def retweet
  @retweet
end

#retweet_countObject (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

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/da_face/twitter/tweet.rb', line 6

def source
  @source
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/da_face/twitter/tweet.rb', line 6

def text
  @text
end

#userObject (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_attributesObject



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_strObject



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 = parse_timestamp(@created_at) if @created_at
  @links = parse_links(@links) if @links
  @id = @id.to_i if @id
end

#retweet?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/da_face/twitter/tweet.rb', line 19

def retweet?
  @retweet || false
end