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
182 183 184 185 186 187 |
# File 'lib/tweepml.rb', line 182 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.
179 180 181 |
# File 'lib/tweepml.rb', line 179 def id @id end |
#screen_name ⇒ Object
Returns the value of attribute screen_name.
179 180 181 |
# File 'lib/tweepml.rb', line 179 def screen_name @screen_name end |
#tags ⇒ Object
Returns the value of attribute tags.
179 180 181 |
# File 'lib/tweepml.rb', line 179 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
179 180 181 |
# File 'lib/tweepml.rb', line 179 def title @title end |
Class Method Details
.find_by_screen_name(screen_name) ⇒ Object
Find a tweep by screen_name
218 219 220 221 222 223 224 225 |
# File 'lib/tweepml.rb', line 218 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
201 202 203 |
# File 'lib/tweepml.rb', line 201 def to_s @screen_name end |
#to_xml ⇒ Object
XML representation of a Tweep
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/tweepml.rb', line 206 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 |