Class: Types::Timedelta

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

Constant Summary

Constants inherited from Typed

Types::Typed::ADDRESS_ZERO, Types::Typed::BYTES20_ZERO, Types::Typed::BYTES32_ZERO, Types::Typed::BYTES_ZERO, Types::Typed::INSCRIPTION_ID_ZERO, Types::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 = 0) ⇒ Timedelta

Returns a new instance of Timedelta.

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
112
113
114
# File 'lib/solidity/typed/numbers.rb', line 105

def initialize( initial_value = 0 )
   ## 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 (and freeze self!) - why? why not?
   @value
end

Class Method Details

.typeObject



101
# File 'lib/solidity/typed/numbers.rb', line 101

def self.type() TimedeltaType.instance; end

.zeroObject



102
# File 'lib/solidity/typed/numbers.rb', line 102

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

Instance Method Details

#zero?Boolean

Returns:

  • (Boolean)


103
# File 'lib/solidity/typed/numbers.rb', line 103

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