Class: Types::Bytes32

Inherits:
TypedValue show all
Defined in:
lib/solidity/typed/values.rb

Constant Summary

Constants inherited from Typed

Typed::ADDRESS_ZERO, Typed::BYTES20_ZERO, Typed::BYTES32_ZERO, Typed::BYTES_ZERO, Typed::INSCRIPTION_ID_ZERO, Typed::STRING_ZERO

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TypedValue

#==, #as_data, #eql?, #hash, #pretty_print, #to_s

Methods inherited from Typed

#as_data, #as_json, dump, serialize, #serialize, #type

Constructor Details

#initialize(initial_value = BYTES32_ZERO) ⇒ Bytes32

Returns a new instance of Bytes32.

Raises:

  • (ArgumentError)


113
114
115
116
117
118
119
120
121
122
# File 'lib/solidity/typed/values.rb', line 113

def initialize( initial_value = BYTES32_ZERO )
   ## was: initial_value ||= type.zero
   ##     check if nil gets passed in - default not used?  

   raise ArgumentError, "expected literal of type #{type}; got typed #{initial_value.pretty_print_inspect}"    if initial_value.is_a?( Typed )    
    
   @value = type.check_and_normalize_literal( initial_value )
   @value.freeze  ## freeze here - why? why not?
   @value   
end

Class Method Details

.typeObject



109
# File 'lib/solidity/typed/values.rb', line 109

def self.type() Bytes32Type.instance; end

.zeroObject



110
# File 'lib/solidity/typed/values.rb', line 110

def self.zero() @zero ||= new; end

Instance Method Details

#zero?Boolean

Returns:

  • (Boolean)


111
# File 'lib/solidity/typed/values.rb', line 111

def zero?()  @value == BYTES32_ZERO; end