Class: TweepList
- Inherits:
-
Object
- Object
- TweepList
- Defined in:
- lib/tweepml.rb
Instance Attribute Summary collapse
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#add_tweep(tweep) ⇒ Object
Add a new Tweep.
-
#add_tweep_list(tweep_list) ⇒ Object
Add a nested TweepList.
-
#find_by_screen_name(screen_name) ⇒ Object
Find a tweep in this list by screen_name.
-
#initialize(title = nil, tags = nil) ⇒ TweepList
constructor
A new instance of TweepList.
-
#to_xml ⇒ Object
XML representation of TweepList.
-
#tweep_lists ⇒ Object
List all TweepLists in this list.
-
#tweeps ⇒ Object
List all tweeps in this list.
Constructor Details
#initialize(title = nil, tags = nil) ⇒ TweepList
Returns a new instance of TweepList.
134 135 136 137 138 139 |
# File 'lib/tweepml.rb', line 134 def initialize(title=nil, =nil) @title = title[0..79] unless title.nil? @tags = @nodes = [] end |
Instance Attribute Details
#tags ⇒ Object
Returns the value of attribute tags.
132 133 134 |
# File 'lib/tweepml.rb', line 132 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
132 133 134 |
# File 'lib/tweepml.rb', line 132 def title @title end |
Instance Method Details
#add_tweep(tweep) ⇒ Object
Add a new Tweep
147 148 149 |
# File 'lib/tweepml.rb', line 147 def add_tweep(tweep) @nodes.push(tweep) unless self.find_by_screen_name(tweep.screen_name) end |
#add_tweep_list(tweep_list) ⇒ Object
Add a nested TweepList
142 143 144 |
# File 'lib/tweepml.rb', line 142 def add_tweep_list(tweep_list) @nodes.push(tweep_list) end |
#find_by_screen_name(screen_name) ⇒ Object
Find a tweep in this list by screen_name
152 153 154 |
# File 'lib/tweepml.rb', line 152 def find_by_screen_name(screen_name) @nodes.select{|t| t.is_a?Tweep and t.screen_name == screen_name}.first end |
#to_xml ⇒ Object
XML representation of TweepList
167 168 169 170 171 172 173 174 175 |
# File 'lib/tweepml.rb', line 167 def to_xml tweep_list = Element.new 'tweep_list' tweep_list.add_attribute('title', @title) unless @title.nil? tweep_list.add_attribute('tags', @tags) unless @tags.nil? @nodes.each{|n| tweep_list.add_element(n.to_xml)} tweep_list end |
#tweep_lists ⇒ Object
List all TweepLists in this list
162 163 164 |
# File 'lib/tweepml.rb', line 162 def tweep_lists @nodes.select{|t| t.is_a?TweepList} end |
#tweeps ⇒ Object
List all tweeps in this list
157 158 159 |
# File 'lib/tweepml.rb', line 157 def tweeps @nodes.select{|t| t.is_a?Tweep} end |