Class: VtdXml::Node
Instance Method Summary
collapse
Methods included from Navigation
#clear_xpath_namespaces, #register_namespaces, #xpath
Constructor Details
#initialize(start_index, navigator, pilot, modifier) ⇒ Node
131
132
133
134
135
136
137
|
# File 'lib/vtd_xml/document.rb', line 131
def initialize(start_index, navigator, pilot, modifier)
@start_index = start_index
@navigator = navigator
@pilot = pilot
@modifier = modifier
@text_for = text_for(start_index)
end
|
Instance Method Details
#remove ⇒ Object
143
144
145
146
|
# File 'lib/vtd_xml/document.rb', line 143
def remove
@navigator.recover_node(@start_index)
@modifier.remove()
end
|
#search(xpath) ⇒ Object
166
167
168
169
|
# File 'lib/vtd_xml/document.rb', line 166
def search(xpath)
@navigator.recover_node(@start_index)
super(xpath)
end
|
#text_for(index) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/vtd_xml/document.rb', line 149
def text_for(index)
if index != -1
case @navigator.get_token_type(index)
when VTDGen::TOKEN_STARTING_TAG
text_for(@navigator.text())
when VTDGen::TOKEN_ATTR_NAME
text_for(@navigator.get_attr_val(@navigator.to_string(index)))
when VTDGen::TOKEN_ATTR_VAL
@navigator.to_normalized_string(index)
when VTDGen::TOKEN_CHARACTER_DATA
@navigator.to_normalized_string(index)
when VTDGen::TOKEN_DOCUMENT
@navigator.to_normalized_string(index)
end
end
end
|
#to_s ⇒ Object
139
140
141
|
# File 'lib/vtd_xml/document.rb', line 139
def to_s
@text_for
end
|