Sha256: 726198d877c31c8e284a780da7a320fb486006a873b97cbd398ac10e30592688
Contents?: true
Size: 973 Bytes
Versions: 1
Compression:
Stored size: 973 Bytes
Contents
require 'pump/xml/node' require 'active_support/core_ext/string/inflections' module Pump class Xml class TagArray < Node def initialize(name, attributes={}, nodes=[], options={}) tag = Tag.new(name, attributes, nodes, {:level => 1, :extra_indent => options[:extra_indent]}) array_root = options[:array_root] || name.to_s.pluralize super(array_root, {}, [tag], options) end def to_s "#{prefix}<#{name} type=\\\"array\\\"#{loop_and_close_tag}" end private def prefix options[:instruct] ? "#{Tag::INSTRUCT}" : tabs end def loop_and_close_tag "\#{ #{objects_path}.empty? ? \" />\n\" : \">\n#{tag_loop}#{tabs}</#{name}>\n\" }" end def objects_path options[:array_method] ? "object.#{options[:array_method]}" : "objects" end def tag_loop "\#{#{objects_path}.map{|object| \"#{nodes.first}\" }.join('')}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pump-0.0.5 | lib/pump/xml/tag_array.rb |