Class: RuBB::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/rubb/node.rb,
lib/rubb/node/url.rb,
lib/rubb/node/text.rb,
lib/rubb/node/email.rb,
lib/rubb/node/image.rb,
lib/rubb/node/quote.rb,
lib/rubb/node/simple.rb,
lib/rubb/node/styled.rb

Direct Known Subclasses

Email, Image, Quote, Simple, Styled, Text, URL

Defined Under Namespace

Classes: Email, Image, Quote, Simple, Styled, Text, URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Node

Returns a new instance of Node.



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

def initialize(options={})
  @children = options[:children] || []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



3
4
5
# File 'lib/rubb/node.rb', line 3

def children
  @children
end

Instance Method Details

#<<(child) ⇒ Object



9
10
11
# File 'lib/rubb/node.rb', line 9

def <<(child)
  @children << child
end

#to_htmlObject



13
14
15
16
17
18
19
# File 'lib/rubb/node.rb', line 13

def to_html
  html = ''
  @children.each do |child|
    html += child ? child.to_html : ''
  end
  html
end