Module: XmlFu
- Defined in:
- lib/xml-fu.rb,
lib/xml-fu/hash.rb,
lib/xml-fu/node.rb,
lib/xml-fu/array.rb,
lib/xml-fu/markup.rb,
lib/xml-fu/version.rb
Defined Under Namespace
Classes: Array, Hash, Markup, Node
Constant Summary
- VERSION =
"0.1.7"- @@infer_simple_value_nodes =
CONFIGURATIONS
false
Class Method Summary (collapse)
- + (Object) configure {|_self| ... }
-
+ (Object) infer_simple_value_nodes
Configuration option to be used with future releases This option should allow for the inferrance of parent node names of simple value types.
-
+ (Object) infer_simple_value_nodes=(val)
Set configuration option to be used with future releases.
-
+ (Object) parse(xml = nil, options = {})
Parse XML into array of hashes.
-
+ (Object) xml(construct, options = {})
Convert construct into XML.
Class Method Details
+ (Object) configure {|_self| ... }
34 35 36 |
# File 'lib/xml-fu.rb', line 34 def configure yield self end |
+ (Object) infer_simple_value_nodes
Configuration option to be used with future releases This option should allow for the inferrance of parent node names of simple value types
Example:
1 => <Integer>1</Integer>
true => <Boolean>true</Boolean>
This is disabled by default as it is conflicting with working logic.
57 58 59 |
# File 'lib/xml-fu.rb', line 57 def infer_simple_value_nodes return @@infer_simple_value_nodes end |
+ (Object) infer_simple_value_nodes=(val)
Set configuration option to be used with future releases
45 46 47 |
# File 'lib/xml-fu.rb', line 45 def infer_simple_value_nodes=(val) @@infer_simple_value_nodes = val end |
+ (Object) parse(xml = nil, options = {})
Add Nori-like parsing capability to convert XML back into XmlFu-compatible Hash/Array
Parse XML into array of hashes. If XML used as input contains only sibling nodes, output will be array of hashes corresponding to those sibling nodes.
<foo/><bar/> => [{"foo/" => ""}, {"bar/" => ""}]
If XML used as input contains a full document with root node, output will be an array of one hash (the root node hash)
<foo><bar/><baz/></foo> => [{"foo" => [{"bar/" => ""},{"baz/" => ""}] }]
28 29 30 31 32 |
# File 'lib/xml-fu.rb', line 28 def parse(xml=nil, ={}) parsed_xml = xml return Array(parsed_xml) end |
+ (Object) xml(construct, options = {})
Convert construct into XML
10 11 12 13 14 15 16 |
# File 'lib/xml-fu.rb', line 10 def xml(construct, ={}) case construct when ::Hash then Hash.to_xml( construct.dup, ) when ::Array then Array.to_xml( construct.dup, ) else nil end end |