Class: EthereumContractABI::ContractInterface::AbiTypes::Uint

Inherits:
Int
  • Object
show all
Defined in:
lib/ethereum-contract-abi/contract/abi_types/uint.rb

Direct Known Subclasses

Address

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Int

#decode_value, #encode_value, #initialize

Methods inherited from BaseType

#bytesize, #decode_value, #encode_value, #is_type_equal

Constructor Details

This class inherits a constructor from EthereumContractABI::ContractInterface::AbiTypes::Int

Class Method Details

.from_string(string_type) ⇒ Object



22
23
24
25
26
# File 'lib/ethereum-contract-abi/contract/abi_types/uint.rb', line 22

def self.from_string(string_type)
  /(?<is_uint>uint)(?<bits>\d+)?/ =~ string_type
  return nil unless is_uint
  bits ? self.new(bits.to_i) : self.new
end

Instance Method Details

#is_dynamicObject



14
15
16
# File 'lib/ethereum-contract-abi/contract/abi_types/uint.rb', line 14

def is_dynamic
  false
end

#to_sObject



10
11
12
# File 'lib/ethereum-contract-abi/contract/abi_types/uint.rb', line 10

def to_s
  "uint#{@bits}"
end

#valid_value?(number) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ethereum-contract-abi/contract/abi_types/uint.rb', line 18

def valid_value?(number)
  super(number) && number >= 0
end