Class: Goodcheck::Pattern::Literal

Inherits:
Object
  • Object
show all
Defined in:
lib/goodcheck/pattern.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, case_sensitive:) ⇒ Literal

Returns a new instance of Literal.



7
8
9
10
# File 'lib/goodcheck/pattern.rb', line 7

def initialize(source:, case_sensitive:)
  @source = source
  @case_sensitive = case_sensitive
end

Instance Attribute Details

#case_sensitiveObject (readonly)

Returns the value of attribute case_sensitive.



5
6
7
# File 'lib/goodcheck/pattern.rb', line 5

def case_sensitive
  @case_sensitive
end

#sourceObject (readonly)

Returns the value of attribute source.



4
5
6
# File 'lib/goodcheck/pattern.rb', line 4

def source
  @source
end

Instance Method Details

#regexpObject



12
13
14
# File 'lib/goodcheck/pattern.rb', line 12

def regexp
  @regexp ||= ::Regexp.compile(::Regexp.escape(source), !case_sensitive)
end