Class: Types::UInt
- Inherits:
-
TypedValue
show all
- Includes:
- Comparable
- Defined in:
- lib/solidity/typed/numbers.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 = 0) ⇒ UInt
Returns a new instance of UInt.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/solidity/typed/numbers.rb', line 9
def initialize( initial_value = 0 )
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 @value
end
|
Class Method Details
.type ⇒ Object
5
|
# File 'lib/solidity/typed/numbers.rb', line 5
def self.type() UIntType.instance; end
|
.zero ⇒ Object
6
|
# File 'lib/solidity/typed/numbers.rb', line 6
def self.zero() @zero ||= UInt.new; end
|
Instance Method Details
#*(other) ⇒ Object
25
|
# File 'lib/solidity/typed/numbers.rb', line 25
def *(other) UInt.new( @value * other.to_int); end
|
#+(other) ⇒ Object
23
|
# File 'lib/solidity/typed/numbers.rb', line 23
def +(other ) UInt.new( @value + other.to_int); end
|
#-(other) ⇒ Object
24
|
# File 'lib/solidity/typed/numbers.rb', line 24
def -(other) UInt.new( @value - other.to_int); end
|
#/(other) ⇒ Object
26
|
# File 'lib/solidity/typed/numbers.rb', line 26
def /(other) UInt.new( @value / other.to_int); end
|
#<=>(other) ⇒ Object
21
|
# File 'lib/solidity/typed/numbers.rb', line 21
def <=>(other) @value <=> other.to_int; end
|
#div(other) ⇒ Object
28
|
# File 'lib/solidity/typed/numbers.rb', line 28
def div(other) UInt.new( @value.div(other.to_int)); end
|
#to_i ⇒ Object
37
|
# File 'lib/solidity/typed/numbers.rb', line 37
def to_i() @value; end
|
#to_int ⇒ Object
36
|
# File 'lib/solidity/typed/numbers.rb', line 36
def to_int() @value; end
|
#zero? ⇒ Boolean
7
|
# File 'lib/solidity/typed/numbers.rb', line 7
def zero?() @value == 0; end
|