Class: RuBB::Node::Text
- Inherits:
-
RuBB::Node
- Object
- RuBB::Node
- RuBB::Node::Text
- Defined in:
- lib/rubb/node/text.rb
Instance Attribute Summary collapse
-
#ignore_whitespace ⇒ Object
Returns the value of attribute ignore_whitespace.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from RuBB::Node
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Text
constructor
A new instance of Text.
- #to_html ⇒ Object
Methods inherited from RuBB::Node
Constructor Details
#initialize(options = {}) ⇒ Text
Returns a new instance of Text.
7 8 9 10 11 |
# File 'lib/rubb/node/text.rb', line 7 def initialize(={}) super() @text = [:text] || '' @ignore_whitespace = [:ignore_whitespace] || false end |
Instance Attribute Details
#ignore_whitespace ⇒ Object
Returns the value of attribute ignore_whitespace.
5 6 7 |
# File 'lib/rubb/node/text.rb', line 5 def ignore_whitespace @ignore_whitespace end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/rubb/node/text.rb', line 4 def text @text end |
Instance Method Details
#to_html ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rubb/node/text.rb', line 13 def to_html if(@ignore_whitespace) @text.gsub(/\s/, '') else @text.gsub(/\r\n?/, "\n").gsub(/\n/, '<br />') end end |