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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PScalarType

#instance?

Methods inherited from PAnyType

#==, #assignable?, #callable?, #callable_args?, #check_self_recursion, #generalize, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #name, new_function, #new_function, #normalize, #really_instance?, #resolve, #simple_name, simple_name, #to_alias_expanded_s, #to_s

Methods inherited from TypedModelObject

_ptype, create_ptype, register_ptypes

Methods included from PuppetObject

#_ptype

Constructor Details

#initialize(patterns) ⇒ PPatternType

Returns a new instance of PPatternType.



1551
1552
1553
# File 'lib/puppet/pops/types/types.rb', line 1551

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

Instance Attribute Details

#patternsObject (readonly)



1549
1550
1551
# File 'lib/puppet/pops/types/types.rb', line 1549

def patterns
  @patterns
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object



1545
1546
1547
# File 'lib/puppet/pops/types/types.rb', line 1545

def self.register_ptype(loader, ir)
  create_ptype(loader, ir, 'ScalarType', 'patterns' => PArrayType.new(PRegexpType::DEFAULT))
end

Instance Method Details

#accept(visitor, guard) ⇒ Object



1555
1556
1557
1558
# File 'lib/puppet/pops/types/types.rb', line 1555

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


1564
1565
1566
# File 'lib/puppet/pops/types/types.rb', line 1564

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

#hashObject



1560
1561
1562
# File 'lib/puppet/pops/types/types.rb', line 1560

def hash
  @patterns.hash
end