Class: LiabilityProof::PrettyPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/liability-proof/pretty_printer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PrettyPrinter

Returns a new instance of PrettyPrinter.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
# File 'lib/liability-proof/pretty_printer.rb', line 4

def initialize(options)
  @json_path = options.delete(:file)
  raise ArgumentError, "file to print unspecified" unless @json_path

  @json = JSON.parse File.read(@json_path)
end

Instance Method Details



11
12
13
14
15
16
17
# File 'lib/liability-proof/pretty_printer.rb', line 11

def print
  if Hash === @json && @json.keys.first == 'partial_tree'
    print_tree @json['partial_tree']
  else
    ap @json
  end
end