Class: Puppet::Pops::Types::PStructElement
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
_ptype, create_ptype, register_ptypes
#_ptype
Constructor Details
#initialize(key_type, value_type) ⇒ PStructElement
Returns a new instance of PStructElement.
1674
1675
1676
1677
|
# File 'lib/puppet/pops/types/types.rb', line 1674
def initialize(key_type, value_type)
@key_type = key_type
@value_type = value_type
end
|
Instance Attribute Details
1657
1658
1659
|
# File 'lib/puppet/pops/types/types.rb', line 1657
def key_type
@key_type
end
|
#value_type ⇒ Object
1657
1658
1659
|
# File 'lib/puppet/pops/types/types.rb', line 1657
def value_type
@value_type
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
1651
1652
1653
1654
1655
|
# File 'lib/puppet/pops/types/types.rb', line 1651
def self.register_ptype(loader, ir)
@type = Pcore::create_object_type(loader, ir, self, 'Pcore::StructElement'.freeze, nil,
'key_type' => PType::DEFAULT,
'value_type' => PType::DEFAULT)
end
|
Instance Method Details
1697
1698
1699
|
# File 'lib/puppet/pops/types/types.rb', line 1697
def <=>(o)
self.name <=> o.name
end
|
1705
1706
1707
|
# File 'lib/puppet/pops/types/types.rb', line 1705
def ==(o)
self.class == o.class && value_type == o.value_type && key_type == o.key_type
end
|
#accept(visitor, guard) ⇒ Object
1659
1660
1661
1662
|
# File 'lib/puppet/pops/types/types.rb', line 1659
def accept(visitor, guard)
@key_type.accept(visitor, guard)
@value_type.accept(visitor, guard)
end
|
#eql?(o) ⇒ Boolean
1701
1702
1703
|
# File 'lib/puppet/pops/types/types.rb', line 1701
def eql?(o)
self == o
end
|
#generalize ⇒ Object
1679
1680
1681
1682
|
# File 'lib/puppet/pops/types/types.rb', line 1679
def generalize
gv_type = @value_type.generalize
@value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
end
|
1664
1665
1666
|
# File 'lib/puppet/pops/types/types.rb', line 1664
def hash
value_type.hash ^ key_type.hash
end
|
1668
1669
1670
1671
1672
|
# File 'lib/puppet/pops/types/types.rb', line 1668
def name
k = key_type
k = k.optional_type if k.is_a?(POptionalType)
k.values[0]
end
|
#normalize(guard = nil) ⇒ Object
1684
1685
1686
1687
|
# File 'lib/puppet/pops/types/types.rb', line 1684
def normalize(guard = nil)
nv_type = @value_type.normalize(guard)
@value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
end
|
#resolve(type_parser, loader) ⇒ Object
1689
1690
1691
1692
1693
1694
1695
|
# File 'lib/puppet/pops/types/types.rb', line 1689
def resolve(type_parser, loader)
rkey_type = @key_type
rkey_type = rkey_type.resolve(type_parser, loader) unless rkey_type.nil?
rvalue_type = @value_type
rvalue_type = rvalue_type.resolve(type_parser, loader) unless rvalue_type.nil?
rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
end
|