Module: Siren::JsonQuery::Match

Defined in:
lib/siren/json_query_nodes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.convert(string) ⇒ Object



259
260
261
262
# File 'lib/siren/json_query_nodes.rb', line 259

def self.convert(string)
  string.gsub(/([\.\+\[\]\{\}\(\)\^\$])/) { "\\#{$1}" }.
         gsub('*', '.*').gsub('?', '.')
end

Instance Method Details

#value(expr1, expr2) ⇒ Object



254
255
256
257
# File 'lib/siren/json_query_nodes.rb', line 254

def value(expr1, expr2)
  return expr1 == expr2 unless expr2.respond_to?(:gsub)
  expr1 =~ %r{^#{Match.convert(expr2)}$}i
end