Class: LiabilityProof::Tree::LeafNode
- Inherits:
-
Struct
- Object
- Struct
- LiabilityProof::Tree::LeafNode
- Includes:
- Node
- Defined in:
- lib/liability-proof/tree/leaf_node.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#nonce ⇒ Object
Returns the value of attribute nonce.
-
#sum ⇒ Object
Returns the value of attribute sum.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, sum, nonce, hash = nil) ⇒ LeafNode
constructor
A new instance of LeafNode.
Methods included from Node
#as_json, #as_user_json, #decimal_to_digits, #sum_string
Constructor Details
#initialize(user, sum, nonce, hash = nil) ⇒ LeafNode
Returns a new instance of LeafNode.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/liability-proof/tree/leaf_node.rb', line 7 def initialize(user, sum, nonce, hash=nil) raise ArgumentError, "sum must be BigDecimal" unless sum.is_a?(BigDecimal) super(user, sum, nonce) self.hash = hash || generate_hash if user && hash && nonce raise ArgumentError, "Hash doesn't match" if generate_hash != hash end end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash
4 5 6 |
# File 'lib/liability-proof/tree/leaf_node.rb', line 4 def hash @hash end |
#nonce ⇒ Object
Returns the value of attribute nonce
4 5 6 |
# File 'lib/liability-proof/tree/leaf_node.rb', line 4 def nonce @nonce end |
#sum ⇒ Object
Returns the value of attribute sum
4 5 6 |
# File 'lib/liability-proof/tree/leaf_node.rb', line 4 def sum @sum end |
#user ⇒ Object
Returns the value of attribute user
4 5 6 |
# File 'lib/liability-proof/tree/leaf_node.rb', line 4 def user @user end |