Class: XmlUtils::Text
Direct Known Subclasses
CData
Instance Attribute Summary collapse
Attributes inherited from Node
#parent
Instance Method Summary
collapse
Methods inherited from ChildNode
#write
Methods inherited from Node
#deep_clone, #document, #each, #next_sibling, #previous_sibling, #remove, #root
Constructor Details
#initialize(value, respect_whitespace = false, parent = nil) ⇒ Text
Returns a new instance of Text.
109
110
111
112
113
114
115
|
# File 'lib/xmlutils/node.rb', line 109
def initialize(value, respect_whitespace = false, parent = nil)
super()
@parent = parent
@raw = false
@unnormalized = nil
@value = respect_whitespace ? value : normalize(value)
end
|
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
107
108
109
|
# File 'lib/xmlutils/node.rb', line 107
def raw
@raw
end
|
#unnormalized ⇒ Object
Returns the value of attribute unnormalized.
107
108
109
|
# File 'lib/xmlutils/node.rb', line 107
def unnormalized
@unnormalized
end
|
#value ⇒ Object
Returns the value of attribute value.
107
108
109
|
# File 'lib/xmlutils/node.rb', line 107
def value
@value
end
|
Instance Method Details
#<=>(other) ⇒ Object
129
130
131
|
# File 'lib/xmlutils/node.rb', line 129
def <=>(other)
other <=> @value
end
|
#clone ⇒ Object
121
122
123
|
# File 'lib/xmlutils/node.rb', line 121
def clone
Text.new(@value, true)
end
|
#empty? ⇒ Boolean
125
126
127
|
# File 'lib/xmlutils/node.rb', line 125
def empty?
@value.nil? || @value.empty?
end
|
#node_type ⇒ Object
117
118
119
|
# File 'lib/xmlutils/node.rb', line 117
def node_type
:text
end
|
#to_s ⇒ Object
133
134
135
|
# File 'lib/xmlutils/node.rb', line 133
def to_s
@value.to_s
end
|
#write_content(output, indent = 0) ⇒ Object
146
147
148
149
150
151
152
|
# File 'lib/xmlutils/node.rb', line 146
def write_content(output, indent = 0)
if @raw
output << @value
else
output << escape(@value)
end
end
|