Class: Puppet::Pops::Types::PRegexpType
Constant Summary
collapse
- DEFAULT =
PRegexpType.new(nil)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, #create, #generalize, #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
_ptype, create_ptype, register_ptypes
Methods included from Visitable
#accept
#_ptype
Constructor Details
#initialize(pattern) ⇒ PRegexpType
Returns a new instance of PRegexpType.
1560
1561
1562
1563
1564
1565
1566
1567
|
# File 'lib/puppet/pops/types/types.rb', line 1560
def initialize(pattern)
if pattern.is_a?(Regexp)
@regexp = pattern
@pattern = pattern.options == 0 ? pattern.source : pattern.to_s
else
@pattern = pattern
end
end
|
Instance Attribute Details
1558
1559
1560
|
# File 'lib/puppet/pops/types/types.rb', line 1558
def pattern
@pattern
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
Instance Method Details
#eql?(o) ⇒ Boolean
1577
1578
1579
|
# File 'lib/puppet/pops/types/types.rb', line 1577
def eql?(o)
self.class == o.class && @pattern == o.pattern
end
|
1573
1574
1575
|
# File 'lib/puppet/pops/types/types.rb', line 1573
def hash
@pattern.hash
end
|
#instance?(o, guard = nil) ⇒ Boolean
1581
1582
1583
|
# File 'lib/puppet/pops/types/types.rb', line 1581
def instance?(o, guard=nil)
o.is_a?(Regexp) && (@pattern.nil? || @pattern == (o.options == 0 ? o.source : o.to_s))
end
|
1569
1570
1571
|
# File 'lib/puppet/pops/types/types.rb', line 1569
def regexp
@regexp ||= Regexp.new(@pattern || '')
end
|