Class: Sanatio::BuiltIn::Matching
- Inherits:
-
Object
- Object
- Sanatio::BuiltIn::Matching
- Defined in:
- lib/sanatio/built-in/matching.rb
Instance Method Summary collapse
-
#initialize(regex) ⇒ Matching
constructor
A new instance of Matching.
- #params ⇒ Object
- #reason(_) ⇒ Object
- #skip?(value) ⇒ Boolean
- #valid?(value) ⇒ Boolean
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
#params ⇒ Object
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
8 9 10 |
# File 'lib/sanatio/built-in/matching.rb', line 8 def skip?(value) !value.respond_to?(:to_str) end |
#valid?(value) ⇒ Boolean
12 13 14 |
# File 'lib/sanatio/built-in/matching.rb', line 12 def valid?(value) @regex.match(value) end |