Class: Types::Typed::MappingType
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(key_type, value_type) ⇒ MappingType
Returns a new instance of MappingType.
16
17
18
19
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 16
def initialize( key_type, value_type )
@key_type = key_type
@value_type = value_type
end
|
Instance Attribute Details
#key_type ⇒ Object
Returns the value of attribute key_type.
14
15
16
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 14
def key_type
@key_type
end
|
#value_type ⇒ Object
Returns the value of attribute value_type.
15
16
17
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 15
def value_type
@value_type
end
|
Class Method Details
.instance(key_type, value_type) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 6
def self.instance( key_type, value_type )
raise ArgumentError, "[MappingType.instance] key_type not a type - got #{key_type}; sorry" unless key_type.is_a?( Type )
raise ArgumentError, "[MappingType.instance] value_type not a type - got #{value_type}; sorry" unless value_type.is_a?( Type )
@instances ||= {}
@instances[ key_type.format+"=>"+value_type.format ] ||= new(key_type, value_type)
end
|
Instance Method Details
#==(other) ⇒ Object
23
24
25
26
27
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 23
def ==(other)
other.is_a?( MappingType ) &&
@key_type == other.key_type &&
@value_type == other.value_type
end
|
20
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 20
def format() "mapping(#{@key_type.format}=>#{@value_type.format})"; end
|
#mut? ⇒ Boolean
39
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 39
def mut?() true; end
|
#new(initial_value) ⇒ Object
41
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 41
def new( initial_value ) typedclass.new( initial_value ); end
|
#new_zero ⇒ Object
40
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 40
def new_zero() typedclass.new; end
|
#typedclass ⇒ Object
37
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 37
def typedclass() Types.const_get( typedclass_name ); end
|
#typedclass_name ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/solidity/typed/metatypes/mapping.rb', line 30
def typedclass_name
key_name = _sanitize_class_name( key_type.typedclass_name )
value_name = _sanitize_class_name( value_type.typedclass_name )
"Mapping‹#{key_name}→#{value_name}›"
end
|