class Web3::Eth::Abi::Tuple
Attributes
parsed_types[R]
types[R]
Public Class Methods
new(types, dims)
click to toggle source
Calls superclass method
Web3::Eth::Abi::Type::new
# File lib/web3/eth/abi/type.rb, line 159 def initialize types, dims super('tuple', '', dims) @types = types @parsed_types = types.map{|t| Type.parse t} end
parse(types, dims)
click to toggle source
# File lib/web3/eth/abi/type.rb, line 126 def self.parse types, dims depth = 0 collected = [] current = '' types.split('').each do |c| case c when ',' then if depth==0 collected << current current = '' else current += c end when '(' then depth += 1 current += c when ')' then depth -= 1 current += c else current += c end end collected << current unless current.empty? Tuple.new collected, dims.map {|x| x[1...-1].to_i} end
Public Instance Methods
==(another_type)
click to toggle source
# File lib/web3/eth/abi/type.rb, line 165 def ==(another_type) another_type.kind_of?(Tuple) && another_type.types == types && another_type.dims == dims end
calculate_size()
click to toggle source
# File lib/web3/eth/abi/type.rb, line 175 def calculate_size if dims.empty? s = 0 parsed_types.each do |type| ts = type.size return nil if ts.nil? s += ts end s else if dims.last == 0 # 0 for dynamic array [] nil else subtype.dynamic? ? nil : dims.last * subtype.size end end end
size()
click to toggle source
# File lib/web3/eth/abi/type.rb, line 171 def size @size ||= calculate_size end
subtype()
click to toggle source
# File lib/web3/eth/abi/type.rb, line 195 def subtype @subtype ||= Tuple.new(types, dims[0...-1]) end