Sha256: 84c78465525fe2e23ff00aa9ee3660cbfb43f2271287b52b72122edc02b77bc5
Contents?: true
Size: 834 Bytes
Versions: 3
Compression:
Stored size: 834 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.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.empty? ? \" />\" : \">#{tag_loop}#{tabs}</#{name}>\" }" end def tag_loop "\#{objects.map{|object| \"#{nodes.first}\" }.join('')}\n" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pump-0.0.4 | lib/pump/xml/tag_array.rb |
pump-0.0.3 | lib/pump/xml/tag_array.rb |
pump-0.0.2 | lib/pump/xml/tag_array.rb |