Class: Wunderbar::TextNode

Inherits:
Node
  • Object
show all
Defined in:
lib/wunderbar/node.rb

Direct Known Subclasses

IndentedTextNode

Constant Summary

Constants inherited from Node

Node::ESCAPE, Node::VOID

Instance Attribute Summary

Attributes inherited from Node

#attrs, #children, #name, #node, #parent, #text

Instance Method Summary collapse

Methods inherited from Node

#add_child, #method_missing, #preserve_spaces?, #walk

Constructor Details

#initialize(*args) ⇒ TextNode

Returns a new instance of TextNode.



214
215
216
# File 'lib/wunderbar/node.rb', line 214

def initialize(*args)
  super(nil, *args)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wunderbar::Node

Instance Method Details

#serialize(options, result, indent) ⇒ Object



218
219
220
221
222
223
224
# File 'lib/wunderbar/node.rb', line 218

def serialize(options, result, indent)
  if options[:space] == :preserve
    result << @text.to_s.gsub(/[&<>\u00A0]/,ESCAPE)
  else
    result << @text.to_s.gsub(/[&<>\u00A0]/,ESCAPE).gsub(/\s+/, ' ')
  end
end