Class: JSON::Spec::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/jsss/matcher.rb

Constant Summary collapse

DataTypes =
{
  :String => String,
  :Integer => Numeric
}

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Matcher

Returns a new instance of Matcher.



8
9
10
11
12
13
14
# File 'lib/jsss/matcher.rb', line 8

def initialize(spec)
  @spec = if spec.is_a? String
    Parser.new(spec).parse
  else
     spec
   end
end

Instance Method Details

#match(obj) ⇒ Object



16
17
18
19
# File 'lib/jsss/matcher.rb', line 16

def match(obj)
  obj = JSON.parse(obj) if obj.is_a? String
  do_match(obj, @spec)
end