Module: Nori
- Extended by:
- Nori
- Included in:
- Nori
- Defined in:
- lib/nori.rb,
lib/nori/parser.rb,
lib/nori/version.rb,
lib/nori/parser/rexml.rb,
lib/nori/core_ext/hash.rb,
lib/nori/string_io_file.rb,
lib/nori/core_ext/object.rb,
lib/nori/core_ext/string.rb,
lib/nori/parser/nokogiri.rb,
lib/nori/xml_utility_node.rb,
lib/nori/string_with_attributes.rb
Defined Under Namespace
Modules: CoreExt, Parser Classes: StringIOFile, StringWithAttributes, XMLUtilityNode
Constant Summary collapse
- VERSION =
"1.1.3"
Instance Attribute Summary collapse
-
#advanced_typecasting ⇒ Object
writeonly
Sets whether to use advanced typecasting.
-
#strip_namespaces ⇒ Object
writeonly
Sets whether to strip namespaces.
Instance Method Summary collapse
-
#advanced_typecasting? ⇒ Boolean
Returns whether to use advanced typecasting.
-
#configure {|_self| ... } ⇒ Object
Yields
self
for configuration. -
#convert_tag(tag) ⇒ Object
Transforms a given
tag
using the specified conversion formula. -
#convert_tags? ⇒ Boolean
Returns whether to convert tags.
-
#convert_tags_to(reset = nil, &block) ⇒ Object
Expects a
block
which receives a tag to convert. -
#parse(xml, parser = nil) ⇒ Object
Translates the given
xml
to a Hash. -
#parser=(parser) ⇒ Object
Sets the
parser
to use. -
#strip_namespaces? ⇒ Boolean
Returns whether to strip namespaces.
Instance Attribute Details
#advanced_typecasting=(value) ⇒ Object (writeonly)
Sets whether to use advanced typecasting.
26 27 28 |
# File 'lib/nori.rb', line 26 def advanced_typecasting=(value) @advanced_typecasting = value end |
#strip_namespaces=(value) ⇒ Object (writeonly)
Sets whether to strip namespaces.
35 36 37 |
# File 'lib/nori.rb', line 35 def strip_namespaces=(value) @strip_namespaces = value end |
Instance Method Details
#advanced_typecasting? ⇒ Boolean
Returns whether to use advanced typecasting. Defaults to true
.
30 31 32 |
# File 'lib/nori.rb', line 30 def advanced_typecasting? @advanced_typecasting != false end |
#configure {|_self| ... } ⇒ Object
Yields self
for configuration.
21 22 23 |
# File 'lib/nori.rb', line 21 def configure yield self end |
#convert_tag(tag) ⇒ Object
Transforms a given tag
using the specified conversion formula.
50 51 52 |
# File 'lib/nori.rb', line 50 def convert_tag(tag) @convert_tag.call(tag) end |
#convert_tags? ⇒ Boolean
Returns whether to convert tags.
55 56 57 |
# File 'lib/nori.rb', line 55 def @convert_tag end |
#convert_tags_to(reset = nil, &block) ⇒ Object
Expects a block
which receives a tag to convert. Accepts nil
for a reset to the default behavior of not converting tags.
45 46 47 |
# File 'lib/nori.rb', line 45 def (reset = nil, &block) @convert_tag = reset || block end |
#parse(xml, parser = nil) ⇒ Object
Translates the given xml
to a Hash. Accepts an optional parser
to use.
10 11 12 13 |
# File 'lib/nori.rb', line 10 def parse(xml, parser = nil) return {} if xml.blank? Parser.parse xml, parser, self end |
#parser=(parser) ⇒ Object
Sets the parser
to use.
16 17 18 |
# File 'lib/nori.rb', line 16 def parser=(parser) Parser.use = parser end |
#strip_namespaces? ⇒ Boolean
Returns whether to strip namespaces. Defaults to false
.
39 40 41 |
# File 'lib/nori.rb', line 39 def strip_namespaces? @strip_namespaces end |