class SXRB::Node
Node
class is simple DOM-like element, which allows easy travesing through restricted part of document structure with children
and parent methods.
Attributes
children[RW]
Public Class Methods
new(*args, &block)
click to toggle source
Internal method used to build DOM-like structure. @api private
Calls superclass method
# File lib/sxrb/node.rb, line 8 def initialize(*args, &block) super(*args, &block) @children = [] end
Public Instance Methods
append(node)
click to toggle source
Internal method used to build DOM-like structure. @api private
# File lib/sxrb/node.rb, line 15 def append(node) node.parent = self @children << node end
content()
click to toggle source
Returns text content of a node (recursively), skipping all markup. @return [String]
Text content of this node and all it's descendants is returned, concatenated.
# File lib/sxrb/node.rb, line 25 def content children.map {|child| child.is_a?(TextNode)? child.text : child.content}.flatten.join('') end