Sha256: 8e374e049c338e922aef47b96d9a135b78d047467bdaf158a0452628cf435137
Contents?: true
Size: 786 Bytes
Versions: 1
Compression:
Stored size: 786 Bytes
Contents
module Flexparser # # A Parser similar to the TagParser but intendet for a collection # of propertys. # @param sub_parser [Wrench] all CollectionParsers need a subparser to # deal with the content of the nodes parsed. This should ideally be # a class that includes Spigots::Wrench and can parse the fragment it # is dealt. # class CollectionParser < TagParser def parse(doc) content(doc).map do |n| next sub_parser.parse(n) if sub_parser next type.parse(n.text) if type n.text end end protected def content(doc) content = doc.xpath(xpaths.valid_paths(doc).reduce(&:union).to_s) return content unless content.empty? options[:required] ? raise_required_error(doc) : content end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flexparser-1.0.2 | lib/flexparser/collection_parser.rb |