Class: Puppet::Pops::Types::PStructElement

Inherits:
TypedModelObject show all
Defined in:
lib/puppet/pops/types/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitable

#accept

Constructor Details

#initialize(key_type, value_type) ⇒ PStructElement

Returns a new instance of PStructElement.



807
808
809
810
# File 'lib/puppet/pops/types/types.rb', line 807

def initialize(key_type, value_type)
  @key_type = key_type
  @value_type = value_type
end

Instance Attribute Details

#key_typeObject



795
796
797
# File 'lib/puppet/pops/types/types.rb', line 795

def key_type
  @key_type
end

#value_typeObject



795
796
797
# File 'lib/puppet/pops/types/types.rb', line 795

def value_type
  @value_type
end

Instance Method Details

#<=>(o) ⇒ Object



816
817
818
# File 'lib/puppet/pops/types/types.rb', line 816

def <=>(o)
  self.name <=> o.name
end

#==(o) ⇒ Object



820
821
822
# File 'lib/puppet/pops/types/types.rb', line 820

def ==(o)
   self.class == o.class && value_type == o.value_type && key_type == o.key_type
end

#generalizeObject



812
813
814
# File 'lib/puppet/pops/types/types.rb', line 812

def generalize
  PStructElement.new(@key_type, @value_type.generalize)
end

#hashObject



797
798
799
# File 'lib/puppet/pops/types/types.rb', line 797

def hash
  value_type.hash * 31 + key_type.hash
end

#nameObject



801
802
803
804
805
# File 'lib/puppet/pops/types/types.rb', line 801

def name
  k = key_type
  k = k.optional_type if k.is_a?(POptionalType)
  k.values[0]
end