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

Constructor Details

#initialize(key_type, value_type) ⇒ PStructElement

Returns a new instance of PStructElement.



1163
1164
1165
1166
# File 'lib/puppet/pops/types/types.rb', line 1163

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

Instance Attribute Details

#key_typeObject



1146
1147
1148
# File 'lib/puppet/pops/types/types.rb', line 1146

def key_type
  @key_type
end

#value_typeObject



1146
1147
1148
# File 'lib/puppet/pops/types/types.rb', line 1146

def value_type
  @value_type
end

Instance Method Details

#<=>(o) ⇒ Object



1178
1179
1180
# File 'lib/puppet/pops/types/types.rb', line 1178

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

#accept(visitor, guard) ⇒ Object



1148
1149
1150
1151
# File 'lib/puppet/pops/types/types.rb', line 1148

def accept(visitor, guard)
  @key_type.accept(visitor, guard)
  @value_type.accept(visitor, guard)
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


1182
1183
1184
# File 'lib/puppet/pops/types/types.rb', line 1182

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

#generalizeObject



1168
1169
1170
1171
# File 'lib/puppet/pops/types/types.rb', line 1168

def generalize
  gv_type = @value_type.generalize
  @value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
end

#hashObject



1153
1154
1155
# File 'lib/puppet/pops/types/types.rb', line 1153

def hash
  value_type.hash ^ key_type.hash
end

#nameObject



1157
1158
1159
1160
1161
# File 'lib/puppet/pops/types/types.rb', line 1157

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

#normalize(guard = nil) ⇒ Object



1173
1174
1175
1176
# File 'lib/puppet/pops/types/types.rb', line 1173

def normalize(guard = nil)
  nv_type = @value_type.normalize(guard)
  @value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
end