Class: LiabilityProof::Tree
- Inherits:
-
Object
- Object
- LiabilityProof::Tree
- Defined in:
- lib/liability-proof/tree.rb,
lib/liability-proof/tree/node.rb,
lib/liability-proof/tree/leaf_node.rb,
lib/liability-proof/tree/internal_node.rb
Defined Under Namespace
Modules: Node Classes: InternalNode, LeafNode
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(accounts, options = {}) ⇒ Tree
constructor
A new instance of Tree.
- #last_user_node ⇒ Object
- #partial(user) ⇒ Object
- #partial_json(user) ⇒ Object
- #root_json ⇒ Object
Constructor Details
#initialize(accounts, options = {}) ⇒ Tree
Returns a new instance of Tree.
13 14 15 16 17 18 19 20 21 |
# File 'lib/liability-proof/tree.rb', line 13 def initialize(accounts, ={}) raise ArgumentError, 'accounts is empty' unless accounts && accounts.size > 0 @accounts = accounts @root = generate @indices = Hash[index_leaves(@root)] @currency = .delete(:currency) || 'BTC' end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/liability-proof/tree.rb', line 11 def root @root end |
Instance Method Details
#last_user_node ⇒ Object
41 42 43 |
# File 'lib/liability-proof/tree.rb', line 41 def last_user_node @user_data end |
#partial(user) ⇒ Object
33 34 35 |
# File 'lib/liability-proof/tree.rb', line 33 def partial(user) _partial user, @root, @indices[user].dup, {} end |
#partial_json(user) ⇒ Object
37 38 39 |
# File 'lib/liability-proof/tree.rb', line 37 def partial_json(user) { 'partial_tree' => partial(user) } end |