Class: Puppet::Pops::Types::PEnumType
Overview
A string type describing the set of strings having one of the given values
Constant Summary
collapse
- DEFAULT =
PEnumType.new(EMPTY_ARRAY)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from PScalarType
#instance?
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #generalize, #instance?, #kind_of_callable?, #normalize, #simple_name, #to_alias_expanded_s, #to_s
Methods included from Visitable
#accept
Constructor Details
#initialize(values) ⇒ PEnumType
Returns a new instance of PEnumType.
544
545
546
|
# File 'lib/puppet/pops/types/types.rb', line 544
def initialize(values)
@values = values.sort.freeze
end
|
Instance Attribute Details
542
543
544
|
# File 'lib/puppet/pops/types/types.rb', line 542
def values
@values
end
|
Instance Method Details
#each(&block) ⇒ Object
Returns Enumerator if no block is given, otherwise, calls the given block with each of the strings for this enum
550
551
552
553
|
# File 'lib/puppet/pops/types/types.rb', line 550
def each(&block)
r = Iterable.on(self)
block_given? ? r.each(&block) : r
end
|
#eql?(o) ⇒ Boolean
568
569
570
|
# File 'lib/puppet/pops/types/types.rb', line 568
def eql?(o)
self.class == o.class && @values == o.values
end
|
564
565
566
|
# File 'lib/puppet/pops/types/types.rb', line 564
def hash
@values.hash
end
|
#iterable?(guard = nil) ⇒ Boolean
555
556
557
|
# File 'lib/puppet/pops/types/types.rb', line 555
def iterable?(guard = nil)
true
end
|
#iterable_type(guard = nil) ⇒ Object
559
560
561
562
|
# File 'lib/puppet/pops/types/types.rb', line 559
def iterable_type(guard = nil)
PStringType::ITERABLE_TYPE
end
|