Class: LiabilityProof::Tree::LeafNode

Inherits:
Struct
  • Object
show all
Includes:
Node
Defined in:
lib/liability-proof/tree/leaf_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#as_json, #formatted_value, #value_string

Constructor Details

#initialize(user, value, nonce, hash = nil) ⇒ LeafNode

Returns a new instance of LeafNode.

Raises:

  • (ArgumentError)


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

def initialize(user, value, nonce, hash=nil)
  raise ArgumentError, "value must be BigDecimal" unless value.is_a?(BigDecimal)

  super(user, value, 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

#hashObject

Returns the value of attribute hash

Returns:

  • (Object)

    the current value of hash



4
5
6
# File 'lib/liability-proof/tree/leaf_node.rb', line 4

def hash
  @hash
end

#nonceObject

Returns the value of attribute nonce

Returns:

  • (Object)

    the current value of nonce



4
5
6
# File 'lib/liability-proof/tree/leaf_node.rb', line 4

def nonce
  @nonce
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



4
5
6
# File 'lib/liability-proof/tree/leaf_node.rb', line 4

def user
  @user
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/liability-proof/tree/leaf_node.rb', line 4

def value
  @value
end