Class: Pump::Xml::TagArray

Inherits:
Node
  • Object
show all
Defined in:
lib/pump/xml/tag_array.rb

Instance Attribute Summary

Attributes inherited from Node

#attributes, #name, #nodes, #options

Instance Method Summary collapse

Methods inherited from Node

#level=

Constructor Details

#initialize(name, attributes = {}, nodes = [], options = {}) ⇒ TagArray

Returns a new instance of TagArray.



7
8
9
10
11
12
13
14
# 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

Instance Method Details

#to_sObject



16
17
18
19
20
21
22
# 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