Class: Puppet::Pops::Types::PStructElement
Overview
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.
1715
1716
1717
1718
|
# File 'lib/puppet/pops/types/types.rb', line 1715
def initialize(key_type, value_type)
@key_type = key_type
@value_type = value_type
end
|
Instance Attribute Details
1698
1699
1700
|
# File 'lib/puppet/pops/types/types.rb', line 1698
def key_type
@key_type
end
|
#value_type ⇒ Object
1698
1699
1700
|
# File 'lib/puppet/pops/types/types.rb', line 1698
def value_type
@value_type
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
1692
1693
1694
1695
1696
|
# File 'lib/puppet/pops/types/types.rb', line 1692
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
1738
1739
1740
|
# File 'lib/puppet/pops/types/types.rb', line 1738
def <=>(o)
self.name <=> o.name
end
|
1746
1747
1748
|
# File 'lib/puppet/pops/types/types.rb', line 1746
def ==(o)
self.class == o.class && value_type == o.value_type && key_type == o.key_type
end
|
#accept(visitor, guard) ⇒ Object
1700
1701
1702
1703
|
# File 'lib/puppet/pops/types/types.rb', line 1700
def accept(visitor, guard)
@key_type.accept(visitor, guard)
@value_type.accept(visitor, guard)
end
|
#eql?(o) ⇒ Boolean
1742
1743
1744
|
# File 'lib/puppet/pops/types/types.rb', line 1742
def eql?(o)
self == o
end
|
#generalize ⇒ Object
1720
1721
1722
1723
|
# File 'lib/puppet/pops/types/types.rb', line 1720
def generalize
gv_type = @value_type.generalize
@value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
end
|
1705
1706
1707
|
# File 'lib/puppet/pops/types/types.rb', line 1705
def hash
value_type.hash ^ key_type.hash
end
|
1709
1710
1711
1712
1713
|
# File 'lib/puppet/pops/types/types.rb', line 1709
def name
k = key_type
k = k.optional_type if k.is_a?(POptionalType)
k.value
end
|
#normalize(guard = nil) ⇒ Object
1725
1726
1727
1728
|
# File 'lib/puppet/pops/types/types.rb', line 1725
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
1730
1731
1732
1733
1734
1735
1736
|
# File 'lib/puppet/pops/types/types.rb', line 1730
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
|