Class: EthereumContractABI::ContractInterface::AbiTypes::String

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseType

#is_type_equal

Class Method Details

.from_string(string_type) ⇒ Object



38
39
40
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 38

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

Instance Method Details

#bytesizeObject



20
21
22
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 20

def bytesize
  nil
end

#decode_value(value) ⇒ Object



34
35
36
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 34

def decode_value(value)
  StringDecoder.decode(value)
end

#encode_value(value) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 29

def encode_value(value)
  raise ArgumentError unless valid_value?(value)
  BytesEncoder.encode(value)
end

#is_dynamicObject



16
17
18
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 16

def is_dynamic
  true
end

#to_sObject



12
13
14
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 12

def to_s
  "string"
end

#valid_value?(value) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/ethereum-contract-abi/contract/abi_types/string.rb', line 24

def valid_value?(value)
  return false unless value.is_a? ::String
  true
end