Class: Sanatio::BuiltIn::Matching

Inherits:
Object
  • Object
show all
Defined in:
lib/sanatio/built-in/matching.rb

Instance Method Summary collapse

Constructor Details

#initialize(regex) ⇒ Matching

Returns a new instance of Matching.



4
5
6
# File 'lib/sanatio/built-in/matching.rb', line 4

def initialize(regex)
  @regex = regex
end

Instance Method Details

#paramsObject



20
21
22
# File 'lib/sanatio/built-in/matching.rb', line 20

def params
  [@regex]
end

#reason(_) ⇒ Object



16
17
18
# File 'lib/sanatio/built-in/matching.rb', line 16

def reason(_)
  :no_match
end

#skip?(value) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/sanatio/built-in/matching.rb', line 8

def skip?(value)
  !value.respond_to?(:to_str)
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/sanatio/built-in/matching.rb', line 12

def valid?(value)
  @regex.match(value)
end