Sha256: 0c875c236ad8b244c841c13aed672f936dd42dc505bb1e5491a8a212f4d83d72
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require "nori/version" require "nori/core_ext" require "nori/parser" module Nori extend self # Translates the given +xml+ to a Hash. Accepts an optional +parser+ to use. def parse(xml, parser = nil) return {} if xml.blank? Parser.parse xml, parser end # Sets the +parser+ to use. def parser=(parser) Parser.use = parser end # Yields +self+ for configuration. def configure yield self end # Sets whether to use advanced typecasting. attr_writer :advanced_typecasting # Returns whether to use advanced typecasting. # Defaults to +true+. def advanced_typecasting? @advanced_typecasting != false end # Sets whether to strip namespaces. attr_writer :strip_namespaces # Returns whether to strip namespaces. # Defaults to +false+. def strip_namespaces? @strip_namespaces end # Expects a +block+ which receives a tag to convert. # Accepts +nil+ for a reset to the default behavior of not converting tags. def convert_tags_to(reset = nil, &block) @convert_tag = reset || block end # Transforms a given +tag+ using the specified conversion formula. def convert_tag(tag) @convert_tag.call(tag) end # Returns whether to convert tags. def convert_tags? @convert_tag end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nori-1.0.0 | lib/nori.rb |