Class: Handsoap::XmlQueryFront::NokogiriDriver
- Inherits:
-
Object
- Object
- Handsoap::XmlQueryFront::NokogiriDriver
show all
- Includes:
- XmlElement
- Defined in:
- lib/handsoap/xml_query_front.rb
Overview
Instance Method Summary
collapse
Methods included from XmlElement
#/, #add_namespace, #assert_prefixes!, #initialize, #native_element, #to_boolean, #to_date, #to_f, #to_i
Instance Method Details
#[](attribute_name) ⇒ Object
334
335
336
337
|
# File 'lib/handsoap/xml_query_front.rb', line 334
def [](attribute_name)
raise ArgumentError.new unless attribute_name.kind_of? String
@element[attribute_name]
end
|
#children ⇒ Object
331
332
333
|
# File 'lib/handsoap/xml_query_front.rb', line 331
def children
NodeSelection.new(@element.children.map{|node| NokogiriDriver.new(node) })
end
|
#node_name ⇒ Object
319
320
321
|
# File 'lib/handsoap/xml_query_front.rb', line 319
def node_name
@element.name
end
|
#node_namespace ⇒ Object
322
323
324
|
# File 'lib/handsoap/xml_query_front.rb', line 322
def node_namespace
@element.namespace.href if @element.namespace
end
|
#to_raw ⇒ Object
341
342
343
|
# File 'lib/handsoap/xml_query_front.rb', line 341
def to_raw
@element.serialize(:encoding => 'UTF-8', :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML)
end
|
#to_s ⇒ Object
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
# File 'lib/handsoap/xml_query_front.rb', line 344
def to_s
if @element.kind_of?(Nokogiri::XML::Text) || @element.kind_of?(Nokogiri::XML::CDATA)
element = @element
elsif @element.kind_of?(Nokogiri::XML::Attr)
return @element.value
else
element = @element.children.first
end
return if element.nil?
if element.kind_of?(Nokogiri::XML::CDATA)
element.serialize(:encoding => 'UTF-8').gsub(/^<!\[CDATA\[/, "").gsub(/\]\]>$/, "")
else
element.serialize(:encoding => 'UTF-8').gsub('<', '<').gsub('>', '>').gsub('"', '"').gsub(''', "'").gsub('&', '&')
end
end
|
#to_xml ⇒ Object
338
339
340
|
# File 'lib/handsoap/xml_query_front.rb', line 338
def to_xml
@element.serialize(:encoding => 'UTF-8')
end
|
#xpath(expression, ns = nil) ⇒ Object
325
326
327
328
329
330
|
# File 'lib/handsoap/xml_query_front.rb', line 325
def xpath(expression, ns = nil)
ns = {} if ns.nil?
ns = @namespaces.merge(ns)
assert_prefixes!(expression, ns)
NodeSelection.new(@element.xpath(expression, ns).map{|node| NokogiriDriver.new(node, ns) })
end
|