class EthereumContractABI::ContractInterface::AbiTypes::Int
Public Class Methods
from_string(string_type)
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 40 def self.from_string(string_type) /(?<is_int>^int)(?<bits>\d+)?/ =~ string_type return nil unless is_int bits ? self.new(bits.to_i) : self.new end
new(bits = 256)
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 12 def initialize(bits = 256) raise ArgumentError.new("8 must be a factor of bits") unless bits % 8 === 0 @bits = bits end
Public Instance Methods
decode_value(value)
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 36 def decode_value(value) IntDecoder.decode(value) end
encode_value(number)
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 31 def encode_value(number) raise ArgumentError unless valid_value?(number) IntEncoder.encode(number) end
is_dynamic()
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 17 def is_dynamic false end
to_s()
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 21 def to_s "int#{@bits}" end
valid_value?(number)
click to toggle source
# File lib/ethereum-contract-abi/contract/abi_types/int.rb, line 25 def valid_value?(number) return false unless number.is_a? Numeric return false unless number.bit_length <= @bits true end