class OFX::Aggregate

Attributes

tag[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/ofx/aggregate.rb, line 7
def initialize(options = {})
  @tag = options[:name] || :ofx
end

Public Instance Methods

root() click to toggle source
# File lib/ofx/aggregate.rb, line 11
def root
  dump(@tag)
end

Protected Instance Methods

build_element_group(tag) click to toggle source
# File lib/ofx/aggregate.rb, line 34
def build_element_group(tag)
  if send(tag).respond_to?(:element_group, true)
    send(tag).send(:element_group)
  else
    dump(tag, send(tag))
  end
end
dump(element, body = nil) click to toggle source
# File lib/ofx/aggregate.rb, line 17
def dump(element, body = nil)
  tag = element.upcase
  "<#{tag}>#{body}</#{tag}>"
end
element_group() click to toggle source
# File lib/ofx/aggregate.rb, line 42
def element_group
  body = elements.inject('') do |result, tag|
    result.dup << build_element_group(tag)
  end
  dump(@tag, body)
end
elements() click to toggle source
# File lib/ofx/aggregate.rb, line 22
def elements
  respond_to?(:order, true) ? sort_by_order : public_methods(false)
end
ordered?() click to toggle source
# File lib/ofx/aggregate.rb, line 26
def ordered?
  respond_to?(:order, true)
end
sort_by_order() click to toggle source
# File lib/ofx/aggregate.rb, line 30
def sort_by_order
  public_methods(false).sort_by { |element| order.index(element.to_s) }
end