Class: Tweep
- Inherits:
-
Object
- Object
- Tweep
- Defined in:
- lib/tweepml.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#screen_name ⇒ Object
Returns the value of attribute screen_name.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.find_by_screen_name(screen_name) ⇒ Object
Find a tweep by screen_name.
Instance Method Summary collapse
-
#initialize(screen_name, id = nil, title = nil, tags = nil) ⇒ Tweep
constructor
Create a new Tweep.
-
#to_s ⇒ Object
String representation of a Tweep.
-
#to_xml ⇒ Object
XML representation of a Tweep.
Constructor Details
#initialize(screen_name, id = nil, title = nil, tags = nil) ⇒ Tweep
Create a new Tweep
176 177 178 179 180 181 |
# File 'lib/tweepml.rb', line 176 def initialize(screen_name, id=nil, title=nil, =nil) @id = id.to_i unless id.nil? @screen_name = screen_name @title = title[0..79] unless title.nil? @tags = end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
173 174 175 |
# File 'lib/tweepml.rb', line 173 def id @id end |
#screen_name ⇒ Object
Returns the value of attribute screen_name.
173 174 175 |
# File 'lib/tweepml.rb', line 173 def screen_name @screen_name end |
#tags ⇒ Object
Returns the value of attribute tags.
173 174 175 |
# File 'lib/tweepml.rb', line 173 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
173 174 175 |
# File 'lib/tweepml.rb', line 173 def title @title end |
Class Method Details
.find_by_screen_name(screen_name) ⇒ Object
Find a tweep by screen_name
212 213 214 215 216 217 218 219 |
# File 'lib/tweepml.rb', line 212 def self.find_by_screen_name(screen_name) found = nil ObjectSpace.each_object(Tweep) { |o| found = o if o.screen_name == screen_name } found end |
Instance Method Details
#to_s ⇒ Object
String representation of a Tweep
195 196 197 |
# File 'lib/tweepml.rb', line 195 def to_s @screen_name end |
#to_xml ⇒ Object
XML representation of a Tweep
200 201 202 203 204 205 206 207 208 209 |
# File 'lib/tweepml.rb', line 200 def to_xml tweep = Element.new 'tweep' [:id, :screen_name, :title, :tags].each do |prop| unless self.send(prop).nil? tweep.add_attribute(prop.to_s, "#{self.send(prop)}") end end tweep end |