Class: Schash::Schema::Rule::Match
- Defined in:
- lib/schash/schema/rule/match.rb
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Match
constructor
A new instance of Match.
- #validate(target, position = []) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(pattern) ⇒ Match
Returns a new instance of Match.
5 6 7 |
# File 'lib/schash/schema/rule/match.rb', line 5 def initialize(pattern) @pattern = pattern end |
Instance Method Details
#validate(target, position = []) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/schash/schema/rule/match.rb', line 9 def validate(target, position = []) errors = [] unless @pattern.match(target) errors << Error.new(position, "does not match #{@pattern.inspect}") end errors end |