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
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PScalarType
#instance?
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #check_self_recursion, #create, #instance?, #kind_of_callable?, #name, #new_function, new_function, #normalize, #really_instance?, #resolve, simple_name, #simple_name, #to_alias_expanded_s, #to_s
_ptype, create_ptype, register_ptypes
Methods included from Visitable
#accept
#_ptype
Constructor Details
#initialize(values) ⇒ PEnumType
Returns a new instance of PEnumType.
697
698
699
|
# File 'lib/puppet/pops/types/types.rb', line 697
def initialize(values)
@values = values.uniq.sort.freeze
end
|
Instance Attribute Details
695
696
697
|
# File 'lib/puppet/pops/types/types.rb', line 695
def values
@values
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
691
692
693
|
# File 'lib/puppet/pops/types/types.rb', line 691
def self.register_ptype(loader, ir)
create_ptype(loader, ir, 'ScalarType', 'values' => PArrayType.new(PStringType::NON_EMPTY))
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
703
704
705
706
|
# File 'lib/puppet/pops/types/types.rb', line 703
def each(&block)
r = Iterable.on(self)
block_given? ? r.each(&block) : r
end
|
#eql?(o) ⇒ Boolean
731
732
733
|
# File 'lib/puppet/pops/types/types.rb', line 731
def eql?(o)
self.class == o.class && @values == o.values
end
|
727
728
729
|
# File 'lib/puppet/pops/types/types.rb', line 727
def hash
@values.hash
end
|
#iterable?(guard = nil) ⇒ Boolean
718
719
720
|
# File 'lib/puppet/pops/types/types.rb', line 718
def iterable?(guard = nil)
true
end
|
#iterable_type(guard = nil) ⇒ Object
722
723
724
725
|
# File 'lib/puppet/pops/types/types.rb', line 722
def iterable_type(guard = nil)
PStringType::ITERABLE_TYPE
end
|