Sha256: a2b8de3eb400c451ddf187687bbb324e6fb7c473015499174dcb19da1d737493
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
module NCMB module Query [ {greaterThan: "$gt"}, {notEqualTo: "$ne"}, {equalTo: nil}, {lessThan: "$lt"}, {lessThanOrEqualTo: "$lte"}, {greaterThanOrEqualTo: "$gte"}, {in: "$in"}, {notIn: "$nin"}, {exists: "$exists"}, {regex: "$regex"}, {inArray: "$inArray"}, {notInArray: "$ninArray"}, {allInArray: "$all"}, ].each do |m| define_method m.keys.first do |name, value| params = {} if m.values.first.nil? params[name] = value else params[name] = {} params[name][m.values.first] = value end @queries[@search_key] << params self end end [ {withinKilometers: "$maxDistanceInKilometers"}, {withinMiles: "$maxDistanceInMiles"}, {withinRadians: "$maxDistanceInRadians"} ].each do |m| define_method m.keys.first do |name, geo, value| params = {} params[name] = { "$nearSphere": geo, } params[name][m.values.first] = value @queries[@search_key] << params self end end def withinSquare(name, geo1, geo2) params = {} params[name] = { "$within": { "$box": [ geo1, geo2 ] } } @queries[@search_key] << params self end def where(name, value) params = {} params[name] = value @queries[@search_key] << params self end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ncmb-ruby-client-0.1.3 | lib/ncmb/query.rb |
ncmb-ruby-client-0.1.2 | lib/ncmb/query.rb |
ncmb-ruby-client-0.1.1 | lib/ncmb/query.rb |