Class: Bbcode::NodeList
- Inherits:
-
Array
- Object
- Array
- Bbcode::NodeList
- Defined in:
- lib/bbcode/node_list.rb
Overview
An array with Elements and strings
Instance Method Summary collapse
-
#initialize(handler, nodes = []) ⇒ NodeList
constructor
A new instance of NodeList.
- #source ⇒ Object
- #to_s ⇒ Object
- #with_handler(handler) ⇒ Object
Constructor Details
#initialize(handler, nodes = []) ⇒ NodeList
Returns a new instance of NodeList.
4 5 6 7 |
# File 'lib/bbcode/node_list.rb', line 4 def initialize( handler, nodes = [] ) super nodes @handler = handler end |
Instance Method Details
#source ⇒ Object
9 10 11 |
# File 'lib/bbcode/node_list.rb', line 9 def source self.map{ |element| element.is_a?(String) ? element : element.source }.join end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/bbcode/node_list.rb', line 13 def to_s self.map{ |element| @handler.apply_element_handler_for_element element }.join end |
#with_handler(handler) ⇒ Object
17 18 19 |
# File 'lib/bbcode/node_list.rb', line 17 def with_handler( handler ) NodeList.new handler, self end |