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(EMPTY_ARRAY)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PScalarType

#instance?

Methods inherited from PAnyType

#==, #assignable?, #callable?, #callable_args?, #generalize, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #normalize, #simple_name, #to_alias_expanded_s, #to_s

Constructor Details

#initialize(patterns) ⇒ PPatternType

Returns a new instance of PPatternType.



1077
1078
1079
# File 'lib/puppet/pops/types/types.rb', line 1077

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

Instance Attribute Details

#patternsObject (readonly)



1075
1076
1077
# File 'lib/puppet/pops/types/types.rb', line 1075

def patterns
  @patterns
end

Instance Method Details

#accept(visitor, guard) ⇒ Object



1081
1082
1083
1084
# File 'lib/puppet/pops/types/types.rb', line 1081

def accept(visitor, guard)
  super
  @patterns.each { |p| p.accept(visitor, guard) }
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


1090
1091
1092
# File 'lib/puppet/pops/types/types.rb', line 1090

def eql?(o)
  self.class == o.class && @patterns.size == o.patterns.size && (@patterns - o.patterns).empty?
end

#hashObject



1086
1087
1088
# File 'lib/puppet/pops/types/types.rb', line 1086

def hash
  @patterns.hash
end