class Puppet::Parser::AST::Regex
Public Class Methods
new(value: nil, file: nil, line: nil, pos: nil)
click to toggle source
Calls superclass method
Puppet::Parser::AST::Leaf::new
# File lib/puppet/parser/ast/leaf.rb 54 def initialize(value: nil, file: nil, line: nil, pos: nil) 55 super(value: value, file: file, line: line, pos: pos) 56 57 # transform value from hash options unless it is already a regular expression 58 @value = Regexp.new(@value) unless @value.is_a?(Regexp) 59 end
Public Instance Methods
evaluate(scope)
click to toggle source
we're returning self here to wrap the regexp and to be used in places where a string would have been used, without modifying any client code. For instance, in many places we have the following code snippet:
val = @val.safeevaluate(@scope)
if val.match(otherval)
...
end
this way, we don't have to modify this test specifically for handling regexes.
# File lib/puppet/parser/ast/leaf.rb 71 def evaluate(scope) 72 self 73 end
match(value)
click to toggle source
# File lib/puppet/parser/ast/leaf.rb 75 def match(value) 76 @value.match(value) 77 end
to_s()
click to toggle source
# File lib/puppet/parser/ast/leaf.rb 79 def to_s 80 Puppet::Pops::Types::PRegexpType.regexp_to_s_with_delimiters(@value) 81 end