Class: Puppet::Pops::Types::PPatternType

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

Overview

Represents a subtype of String that narrows the string to those matching the patterns If specified without a pattern it is basically the same as the String type.

Constant Summary collapse

DEFAULT =
PPatternType.new([])

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PScalarType

#instance?

Methods inherited from PAnyType

#assignable?, #callable?, #callable_args?, #enumerable?, #generalize, #instance?, #kind_of_callable?, #simple_name, #to_s

Methods included from Visitable

#accept

Constructor Details

#initialize(patterns) ⇒ PPatternType

Returns a new instance of PPatternType.



731
732
733
# File 'lib/puppet/pops/types/types.rb', line 731

def initialize(patterns)
  @patterns = patterns.freeze
end

Instance Attribute Details

#patternsObject (readonly)



729
730
731
# File 'lib/puppet/pops/types/types.rb', line 729

def patterns
  @patterns
end

Instance Method Details

#==(o) ⇒ Object



739
740
741
# File 'lib/puppet/pops/types/types.rb', line 739

def ==(o)
  self.class == o.class && (@patterns | o.patterns).size == @patterns.size
end

#hashObject



735
736
737
# File 'lib/puppet/pops/types/types.rb', line 735

def hash
  @patterns.hash
end