Class: Puppet::Pops::Types::PEnumType
- Inherits:
-
PScalarType
- Object
- TypedModelObject
- PAnyType
- PScalarType
- Puppet::Pops::Types::PEnumType
- Includes:
- Enumerable
- Defined in:
- lib/puppet/pops/types/types.rb
Overview
A string type describing the set of strings having one of the given values
Constant Summary collapse
- DEFAULT =
PEnumType.new([])
Instance Attribute Summary collapse
- #values ⇒ Object readonly
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#each ⇒ Object
Returns Enumerator if no block is given, otherwise, calls the given block with each of the strings for this enum.
- #hash ⇒ Object
-
#initialize(values) ⇒ PEnumType
constructor
A new instance of PEnumType.
Methods inherited from PScalarType
Methods inherited from PAnyType
#assignable?, #callable?, #callable_args?, #enumerable?, #generalize, #instance?, #kind_of_callable?, #simple_name, #to_s
Methods included from Visitable
Constructor Details
#initialize(values) ⇒ PEnumType
Returns a new instance of PEnumType.
375 376 377 |
# File 'lib/puppet/pops/types/types.rb', line 375 def initialize(values) @values = values.sort.freeze end |
Instance Attribute Details
#values ⇒ Object (readonly)
373 374 375 |
# File 'lib/puppet/pops/types/types.rb', line 373 def values @values end |
Instance Method Details
#==(o) ⇒ Object
393 394 395 |
# File 'lib/puppet/pops/types/types.rb', line 393 def ==(o) self.class == o.class && @values == o.values end |
#each ⇒ Object
Returns Enumerator if no block is given, otherwise, calls the given block with each of the strings for this enum
381 382 383 384 385 386 387 |
# File 'lib/puppet/pops/types/types.rb', line 381 def each if block_given? values.each { |x| yield x } else values.to_enum end end |
#hash ⇒ Object
389 390 391 |
# File 'lib/puppet/pops/types/types.rb', line 389 def hash @values.hash end |