Class: LiabilityProof::Generator

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Generator

Returns a new instance of Generator.



6
7
8
9
10
11
12
13
14
15
# File 'lib/liability-proof/generator.rb', line 6

def initialize(options)
  @accounts_path     = options.delete(:file) || 'accounts.json'
  @root_path         = options.delete(:root) || 'root.json'

  @partial_trees_dir = options.delete(:partial_trees_dir) || 'partial_trees'
  FileUtils.mkdir @partial_trees_dir unless File.exists?(@partial_trees_dir)

  accounts = JSON.parse File.read(@accounts_path)
  @tree    = LiabilityProof::Tree.new accounts, options
end

Instance Method Details

#write!Object



17
18
19
20
# File 'lib/liability-proof/generator.rb', line 17

def write!
  write_root_json
  @tree.indices.keys.each {|user| write_partial_tree(user) }
end