Class: TwitterSearch::Tweet

Inherits:
Object
  • Object
show all
Defined in:
lib/tweets.rb

Constant Summary collapse

VARS =
[:text, :from_user, :to_user, :to_user_id, :id, :iso_language_code, :from_user_id, :created_at, :profile_image_url, :source, :geo ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Tweet

Returns a new instance of Tweet.



7
8
9
10
# File 'lib/tweets.rb', line 7

def initialize(opts)
  @language = opts['iso_language_code']                   
  VARS.each { |each| instance_variable_set "@#{each}", opts[each.to_s] }
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language.



5
6
7
# File 'lib/tweets.rb', line 5

def language
  @language
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/tweets.rb', line 13

def eql?(other)
  self.hash == other.hash
end

#hashObject



17
18
19
# File 'lib/tweets.rb', line 17

def hash
  @id
end

#to_hashObject



21
22
23
24
25
# File 'lib/tweets.rb', line 21

def to_hash
  hsh = Hash.new
  VARS.each{ |k| hsh[k] = instance_variable_get "@#{k}"}
  hsh
end