Class: TagTreeScanner::TextNode
- Inherits:
-
Object
- Object
- TagTreeScanner::TextNode
- Defined in:
- lib/tagtreescanner.rb
Overview
A TextNode holds raw text inside a Tag. Generally, TextNodes are created automatically by the Tag#<< method.
Instance Attribute Summary collapse
-
#info ⇒ Object
A hash which may be used to store ‘extra’ information.
-
#next_sibling ⇒ Object
The Tag or TextNode that comes after this one (may be
nil). -
#parent_tag ⇒ Object
The Tag that is a parent of this TextNode (may be
nil). -
#previous_sibling ⇒ Object
The Tag or TextNode that comes before this one (may be
nil). -
#text ⇒ Object
The string contents of this text node.
Instance Method Summary collapse
-
#<<(additional_text) ⇒ Object
- additional_text
-
The text to add.
-
#dup ⇒ Object
Returns a copy of this text node.
-
#initialize(text = '') ⇒ TextNode
constructor
- text
-
The text to start out with.
-
#to_hier(level = 0) ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
:nodoc:.
-
#to_xml(*args) ⇒ Object
Returns the contents of this node, modified to be made XML-safe by calling String#xmlsafe.
Constructor Details
#initialize(text = '') ⇒ TextNode
- text
-
The text to start out with
530 531 532 533 |
# File 'lib/tagtreescanner.rb', line 530 def initialize( text='' ) @text = text @info = {} end |
Instance Attribute Details
#info ⇒ Object
A hash which may be used to store ‘extra’ information
524 525 526 |
# File 'lib/tagtreescanner.rb', line 524 def info @info end |
#next_sibling ⇒ Object
The Tag or TextNode that comes after this one (may be nil)
515 516 517 |
# File 'lib/tagtreescanner.rb', line 515 def next_sibling @next_sibling end |
#parent_tag ⇒ Object
The Tag that is a parent of this TextNode (may be nil)
521 522 523 |
# File 'lib/tagtreescanner.rb', line 521 def parent_tag @parent_tag end |
#previous_sibling ⇒ Object
The Tag or TextNode that comes before this one (may be nil)
518 519 520 |
# File 'lib/tagtreescanner.rb', line 518 def previous_sibling @previous_sibling end |
#text ⇒ Object
The string contents of this text node
527 528 529 |
# File 'lib/tagtreescanner.rb', line 527 def text @text end |
Instance Method Details
#<<(additional_text) ⇒ Object
- additional_text
-
The text to add
Appends the provided text to the end of the current text
Returns the new text value
540 541 542 |
# File 'lib/tagtreescanner.rb', line 540 def << ( additional_text ) @text << additional_text end |
#dup ⇒ Object
Returns a copy of this text node
545 546 547 |
# File 'lib/tagtreescanner.rb', line 545 def dup tag = self.class.new( @text.dup ) end |
#to_hier(level = 0) ⇒ Object
:nodoc:
549 550 551 |
# File 'lib/tagtreescanner.rb', line 549 def to_hier( level=0 ) #:nodoc: "#{"\t"*level}#{@text.inspect}\n" end |
#to_s ⇒ Object
:nodoc:
553 554 555 |
# File 'lib/tagtreescanner.rb', line 553 def to_s #:nodoc: @text end |
#to_xml(*args) ⇒ Object
Returns the contents of this node, modified to be made XML-safe by calling String#xmlsafe.
559 560 561 |
# File 'lib/tagtreescanner.rb', line 559 def to_xml( *args ) @text.xmlsafe end |