Class: EthereumContractABI::ContractInterface::AbiTypes::Bool

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseType

#bytesize, #decode_value, #is_type_equal

Class Method Details

.from_string(string_type) ⇒ Object



27
28
29
# File 'lib/ethereum-contract-abi/contract/abi_types/bool.rb', line 27

def self.from_string(string_type)
  string_type === 'bool' ? self.new : nil
end

Instance Method Details

#encode_value(bool) ⇒ Object

Raises:

  • (ArgumentError)


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

def encode_value(bool)
  raise ArgumentError unless valid_value?(bool)
  IntEncoder.encode(bool ? 1 : 0)
end

#is_dynamicObject



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

def is_dynamic
  false
end

#to_sObject



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

def to_s
  "bool"
end

#valid_value?(bool) ⇒ Boolean

Returns:

  • (Boolean)


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

def valid_value?(bool)
  [true, false].include? bool
end