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
678 679 680 681 |
# File 'lib/tagtreescanner.rb', line 678 def initialize( text='' ) @text = text @info = {} end |
Instance Attribute Details
#info ⇒ Object
A hash which may be used to store ‘extra’ information
672 673 674 |
# File 'lib/tagtreescanner.rb', line 672 def info @info end |
#next_sibling ⇒ Object
The Tag or TextNode that comes after this one (may be nil
)
663 664 665 |
# File 'lib/tagtreescanner.rb', line 663 def next_sibling @next_sibling end |
#parent_tag ⇒ Object
The Tag that is a parent of this TextNode (may be nil
)
669 670 671 |
# File 'lib/tagtreescanner.rb', line 669 def parent_tag @parent_tag end |
#previous_sibling ⇒ Object
The Tag or TextNode that comes before this one (may be nil
)
666 667 668 |
# File 'lib/tagtreescanner.rb', line 666 def previous_sibling @previous_sibling end |
#text ⇒ Object
The string contents of this text node
675 676 677 |
# File 'lib/tagtreescanner.rb', line 675 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
688 689 690 |
# File 'lib/tagtreescanner.rb', line 688 def << ( additional_text ) @text << additional_text end |
#dup ⇒ Object
Returns a copy of this text node
693 694 695 |
# File 'lib/tagtreescanner.rb', line 693 def dup tag = self.class.new( @text.dup ) end |
#to_hier(level = 0) ⇒ Object
:nodoc:
697 698 699 |
# File 'lib/tagtreescanner.rb', line 697 def to_hier( level=0 ) #:nodoc: "#{"\t"*level}#{@text.inspect}\n" end |
#to_s ⇒ Object
:nodoc:
701 702 703 |
# File 'lib/tagtreescanner.rb', line 701 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.
707 708 709 |
# File 'lib/tagtreescanner.rb', line 707 def to_xml( *args ) @text.xmlsafe end |