Sha256: b5ada80bb9c5539b57008c14918eac6867cf22070db22f18d75302c0813d891a
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
module MoneyS3 module Parsers module BaseParser EMPTY_ARRAY = [] attr_accessor :raw def initialize(raw) @raw = raw end def attributes raw.attributes end private def at(locator) return nil if raw.nil? element = raw.locate(locator.to_s).first if element text = WithAttributes.new(element.text) text.attributes = element.attributes text end end def has?(locator) raw.locate(locator).any? end def submodel_at(klass, locator) element_xml = raw.locate(locator).first klass.new(element_xml) if element_xml end def array_of_at(klass, locator) return EMPTY_ARRAY if raw.nil? elements = raw.locate([*locator].join('/')) elements.map do |element| klass.new(element) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
money_s3-0.6.0 | lib/money_s3/parsers/base_parser.rb |