Class: XMLCodec::XMLTextElement
- Inherits:
-
Object
- Object
- XMLCodec::XMLTextElement
- Defined in:
- lib/subelements.rb
Overview
A simple element that has only text inside. This is used inside XMLSubElements to be able to directly add strings to it and have them be treated as XML text elements.
Instance Attribute Summary collapse
-
#__parent ⇒ Object
Returns the value of attribute __parent.
Instance Method Summary collapse
-
#create_xml(parent) ⇒ Object
Creates the XML for the element by using add_text on the value.
- #elname ⇒ Object
- #end_partial_export(file) ⇒ Object
-
#initialize(string) ⇒ XMLTextElement
constructor
Create a new element for the given string.
- #partial_export(file) ⇒ Object
- #start_partial_export(file) ⇒ Object
-
#to_s ⇒ Object
Simple to_s method that just returns the included string.
-
#xml_text ⇒ Object
The XML text of the element is simply it’s string value.
Constructor Details
#initialize(string) ⇒ XMLTextElement
Create a new element for the given string.
9 10 11 |
# File 'lib/subelements.rb', line 9 def initialize(string) @value = XMLCodec::XMLUtils::escape_xml(string) end |
Instance Attribute Details
#__parent ⇒ Object
Returns the value of attribute __parent.
6 7 8 |
# File 'lib/subelements.rb', line 6 def __parent @__parent end |
Instance Method Details
#create_xml(parent) ⇒ Object
Creates the XML for the element by using add_text on the value.
19 20 21 |
# File 'lib/subelements.rb', line 19 def create_xml(parent) parent << Nokogiri::XML::Text.new(@value, parent) end |
#elname ⇒ Object
40 41 42 |
# File 'lib/subelements.rb', line 40 def elname '__TEXT__' end |
#end_partial_export(file) ⇒ Object
28 29 |
# File 'lib/subelements.rb', line 28 def end_partial_export(file) end |
#partial_export(file) ⇒ Object
35 36 37 38 |
# File 'lib/subelements.rb', line 35 def partial_export(file) start_partial_export(file) end_partial_export(file) end |
#start_partial_export(file) ⇒ Object
31 32 33 |
# File 'lib/subelements.rb', line 31 def start_partial_export(file) file << self.xml_text end |
#to_s ⇒ Object
Simple to_s method that just returns the included string
14 15 16 |
# File 'lib/subelements.rb', line 14 def to_s @value end |
#xml_text ⇒ Object
The XML text of the element is simply it’s string value.
24 25 26 |
# File 'lib/subelements.rb', line 24 def xml_text @value end |