Module: Hippo::Outputters::PrettyString::TransactionSet

Included in:
TransactionSets::Base
Defined in:
lib/hippo/outputters/pretty_string.rb

Instance Method Summary collapse

Instance Method Details

#pretty_print(pp) ⇒ Object



4
5
6
# File 'lib/hippo/outputters/pretty_string.rb', line 4

def pretty_print(pp)
  pp.text to_pretty_string
end

#to_pretty_string(indent_level = 0) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hippo/outputters/pretty_string.rb', line 8

def to_pretty_string(indent_level = 0)
  output = ''

  values.sort.each do |sequence, component|
    component_definition = self.class.components[sequence]

    extra_indent = if component_definition.klass.ancestors.include?(Hippo::TransactionSets::Base)
                     2
                   elsif sequence == 0
                     0
                   else
                     2
                   end

    output += component.to_pretty_string(indent_level + extra_indent)
  end

  output
end