Class: ScraperWiki::API::Matchers::FieldKeyMatcher
Instance Method Summary
collapse
Instance Method Details
#difference(v) ⇒ Object
768
769
770
|
# File 'lib/scraperwiki-api/matchers.rb', line 768
def difference(v)
raise NotImplementerError, 'Subclasses must implement this method'
end
|
#failure_predicate ⇒ Object
772
773
774
|
# File 'lib/scraperwiki-api/matchers.rb', line 772
def failure_predicate
"#{predicate}: #{difference.join ', '}"
end
|
#match?(v) ⇒ Boolean
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
# File 'lib/scraperwiki-api/matchers.rb', line 751
def match?(v)
w = Yajl::Parser.parse v
if Hash === w
difference(w).empty?
elsif Array === w
w.all? do |x|
if Hash === x
difference(x).empty?
else
raise NotImplementerError, 'Can only handle subfields that are hashes or arrays of hashes'
end
end
else
raise NotImplementerError, 'Can only handle subfields that are hashes or arrays of hashes'
end
end
|
#negative_failure_predicate ⇒ Object
776
777
778
|
# File 'lib/scraperwiki-api/matchers.rb', line 776
def negative_failure_predicate
"#{negative_predicate}: #{difference.join ', '}"
end
|