class Pump::Xml::TagArray

Public Class Methods

new(name, attributes={}, nodes=[], options={}) click to toggle source
Calls superclass method Pump::Xml::Node::new
# File lib/pump/xml/tag_array.rb, line 7
def initialize(name, attributes={}, nodes=[], options={})
  tag = Tag.new(name, attributes, nodes, {
    :level => 1, :extra_indent => options[:extra_indent],
    :xml_key_style => options[:xml_key_style]
  })
  array_root = options[:array_root] || name.to_s.pluralize
  super(array_root, {}, [tag], options)
end

Public Instance Methods

to_s() click to toggle source
# File lib/pump/xml/tag_array.rb, line 16
def to_s
  if options.has_key?(:static_value)
    "#{prefix}<#{format_name name} type=\\\"array\\\"#{static_value_and_close_tag}"
  else
    "#{prefix}<#{format_name name} type=\\\"array\\\"#{loop_and_close_tag}"
  end
end

Private Instance Methods

loop_and_close_tag() click to toggle source
# File lib/pump/xml/tag_array.rb, line 30
def loop_and_close_tag
  "\#{ #{objects_path}.empty? ? \"/>\n\" : \">\n#{tag_loop}#{tabs}</#{format_name name}>\n\" }"
end
objects_path() click to toggle source
# File lib/pump/xml/tag_array.rb, line 39
def objects_path
  options[:array_method] ? "object.#{options[:array_method]}" : "objects"
end
prefix() click to toggle source
# File lib/pump/xml/tag_array.rb, line 26
def prefix
  options[:instruct] ? "#{Tag::INSTRUCT}" : tabs
end
static_value_and_close_tag() click to toggle source
# File lib/pump/xml/tag_array.rb, line 34
def static_value_and_close_tag
  return "/>\n" if options[:static_value].nil?
  ">#{options[:static_value]}</#{format_name name}>\n"
end
tag_loop() click to toggle source
# File lib/pump/xml/tag_array.rb, line 43
def tag_loop
  "\#{#{objects_path}.map{|object| \"#{nodes.first}\" }.join('')}"
end