Class: Types::Typed::ArrayType
Overview
note: dynamic array for now (NOT fixed!!!! - add FixedArray - why? why not?)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Type
#array?, #check_and_normalize_literal, #eql?, #hash, #mapping?, #parse_integer, #pretty_print, #raise_type_error, #zero
Constructor Details
#initialize(sub_type, size = 0) ⇒ ArrayType
Returns a new instance of ArrayType.
18
19
20
21
|
# File 'lib/solidity/typed/metatypes/array.rb', line 18
def initialize( sub_type, size=0 )
@sub_type = sub_type
@size = size
end
|
Instance Attribute Details
#size ⇒ Object
rename size to dim(ension) or such - why? why not?
17
18
19
|
# File 'lib/solidity/typed/metatypes/array.rb', line 17
def size
@size
end
|
#sub_type ⇒ Object
Returns the value of attribute sub_type.
16
17
18
|
# File 'lib/solidity/typed/metatypes/array.rb', line 16
def sub_type
@sub_type
end
|
Class Method Details
.instance(sub_type, size = 0) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/solidity/typed/metatypes/array.rb', line 6
def self.instance( sub_type, size=0 )
raise ArgumentError, "[ArrayType.instance] sub_type not a type - got #{sub_type}; sorry" unless sub_type.is_a?( Type )
@instances ||= {}
key = '' key += sub_type.format
key += "×#{size}" if size != 0
@instances[ key ] ||= new( sub_type, size )
end
|
Instance Method Details
#==(other) ⇒ Object
31
32
33
34
35
|
# File 'lib/solidity/typed/metatypes/array.rb', line 31
def ==(other)
other.is_a?( ArrayType ) &&
@sub_type == other.sub_type &&
@size == other.size end
|
22
23
24
25
26
27
28
|
# File 'lib/solidity/typed/metatypes/array.rb', line 22
def format
if @size == 0 "#{@sub_type.format}[]"
else
"#{@sub_type.format}[#{@size}]"
end
end
|
#mut? ⇒ Boolean
49
|
# File 'lib/solidity/typed/metatypes/array.rb', line 49
def mut?() true; end
|
#new(initial_value) ⇒ Object
51
|
# File 'lib/solidity/typed/metatypes/array.rb', line 51
def new( initial_value ) typedclass.new( initial_value ); end
|
#new_zero ⇒ Object
50
|
# File 'lib/solidity/typed/metatypes/array.rb', line 50
def new_zero() typedclass.new; end
|
#typedclass ⇒ Object
47
|
# File 'lib/solidity/typed/metatypes/array.rb', line 47
def typedclass() Types.const_get( typedclass_name ); end
|
#typedclass_name ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/solidity/typed/metatypes/array.rb', line 38
def typedclass_name
sub_name = _sanitize_class_name( @sub_type.typedclass_name )
name = '' name += "Array‹#{sub_name}›"
name += "×#{size}" if @size != 0
name
end
|