Class: Web3::Eth::Abi::Tuple
Instance Attribute Summary collapse
-
#parsed_types ⇒ Object
readonly
Returns the value of attribute parsed_types.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Attributes inherited from Type
Class Method Summary collapse
Instance Method Summary collapse
- #==(another_type) ⇒ Object
- #calculate_size ⇒ Object
-
#initialize(types, dims) ⇒ Tuple
constructor
A new instance of Tuple.
- #size ⇒ Object
- #subtype ⇒ Object
Methods inherited from Type
Constructor Details
Instance Attribute Details
#parsed_types ⇒ Object (readonly)
Returns the value of attribute parsed_types.
158 159 160 |
# File 'lib/web3/eth/abi/type.rb', line 158 def parsed_types @parsed_types end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
158 159 160 |
# File 'lib/web3/eth/abi/type.rb', line 158 def types @types end |
Class Method Details
.parse(types, dims) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# 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 end |
Instance Method Details
#==(another_type) ⇒ Object
165 166 167 168 169 |
# 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 ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# 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 ⇒ Object
171 172 173 |
# File 'lib/web3/eth/abi/type.rb', line 171 def size @size ||= calculate_size end |