Class: Types::Typed::StructType
- Inherits:
-
ReferenceType
- Object
- Type
- ReferenceType
- Types::Typed::StructType
- Defined in:
- lib/solidity/typed/metatypes/types.rb
Instance Attribute Summary collapse
-
#struct_class ⇒ Object
readonly
reference struct_class here - why? why not?.
-
#struct_name ⇒ Object
readonly
Returns the value of attribute struct_name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#abi ⇒ Object
note: abi requires “tuple()”.
- #format ⇒ Object (also: #to_s)
-
#initialize(struct_name, struct_class) ⇒ StructType
constructor
A new instance of StructType.
-
#mut? ⇒ Boolean
note: mut? == true MUST use new_zero (dup) mut? == false MUST use zero (frozen/shared/singelton).
-
#new(initial_values) ⇒ Object
todo/check: change to values with splat - why? why not?.
- #new_zero ⇒ Object
- #typedclass ⇒ Object
- #typedclass_name ⇒ Object
Methods inherited from Type
#array?, #check_and_normalize_literal, #eql?, #hash, #mapping?, #parse_integer, #pretty_print, #raise_type_error, #zero
Constructor Details
#initialize(struct_name, struct_class) ⇒ StructType
Returns a new instance of StructType.
353 354 355 356 |
# File 'lib/solidity/typed/metatypes/types.rb', line 353 def initialize( struct_name, struct_class ) @struct_name = struct_name @struct_class = struct_class end |
Instance Attribute Details
#struct_class ⇒ Object (readonly)
reference struct_class here - why? why not?
352 353 354 |
# File 'lib/solidity/typed/metatypes/types.rb', line 352 def struct_class @struct_class end |
#struct_name ⇒ Object (readonly)
Returns the value of attribute struct_name.
351 352 353 |
# File 'lib/solidity/typed/metatypes/types.rb', line 351 def struct_name @struct_name end |
Instance Method Details
#==(other) ⇒ Object
371 372 373 374 375 |
# File 'lib/solidity/typed/metatypes/types.rb', line 371 def ==(other) other.is_a?( StructType ) && @struct_name == other.struct_name && ## check for name too - why? why not? @struct_class == other.struct_class end |
#abi ⇒ Object
note: abi requires “tuple()”
366 367 368 369 |
# File 'lib/solidity/typed/metatypes/types.rb', line 366 def abi types = @struct_class.attributes.map {|_,type| type.abi } "tuples(#{types.join(',')})" end |
#format ⇒ Object Also known as: to_s
357 358 359 360 361 |
# File 'lib/solidity/typed/metatypes/types.rb', line 357 def format ## use tuple here (not struct) - why? why not? named_types = @struct_class.attributes.map {|key,type| "#{key} #{type.format}" } "#{@struct_name} struct(#{named_types.join(',')})" end |
#mut? ⇒ Boolean
note: mut? == true MUST use new_zero (dup)
mut? == false MUST use zero (frozen/shared/singelton)
383 |
# File 'lib/solidity/typed/metatypes/types.rb', line 383 def mut?() true; end |
#new(initial_values) ⇒ Object
todo/check: change to values with splat - why? why not?
385 386 387 388 389 |
# File 'lib/solidity/typed/metatypes/types.rb', line 385 def new( initial_values ) ## todo/check: change to values with splat - why? why not? ## note: use "splat" here - must be empty or matching number of fields/attributes ## change - why? why not? @struct_class.new( *initial_values ) end |
#new_zero ⇒ Object
384 |
# File 'lib/solidity/typed/metatypes/types.rb', line 384 def new_zero() @struct_class.new_zero; end |
#typedclass ⇒ Object
379 |
# File 'lib/solidity/typed/metatypes/types.rb', line 379 def typedclass() @struct_class; end |
#typedclass_name ⇒ Object
378 |
# File 'lib/solidity/typed/metatypes/types.rb', line 378 def typedclass_name() @struct_class.name; end |