Class: JSONdb::ResultSet
- Inherits:
-
Object
- Object
- JSONdb::ResultSet
- Defined in:
- lib/jsondb/result_set.rb
Instance Method Summary collapse
- #equal(field, value) ⇒ Object
-
#initialize(table_name) ⇒ ResultSet
constructor
A new instance of ResultSet.
- #interval(field, min, max) ⇒ Object
- #like(field, value) ⇒ Object
- #max(field, value) ⇒ Object
- #min(field, value) ⇒ Object
-
#result ⇒ Object
TODO: For next version TODO: Change it, it must compare all records at the same time all_records.each do |r| eq.each do |k,v| ok if match ok_array << ok end if ok_Array.all == true then it match.
Constructor Details
#initialize(table_name) ⇒ ResultSet
Returns a new instance of ResultSet.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jsondb/result_set.rb', line 5 def initialize(table_name) @table_name = table_name @result = Hash.new # TODO: It must not be here, jsut a workaround atm JSONdb.records[@table_name].each do |k, v| @result[k] = v.dup end @equal = Hash.new @min = Hash.new @max = Hash.new @like = Hash.new end |
Instance Method Details
#equal(field, value) ⇒ Object
21 22 23 24 |
# File 'lib/jsondb/result_set.rb', line 21 def equal(field, value) @equal[field] = value return self end |
#interval(field, min, max) ⇒ Object
36 37 38 39 40 |
# File 'lib/jsondb/result_set.rb', line 36 def interval(field, min, max) @min[field] = min @max[field] = max return self end |
#like(field, value) ⇒ Object
42 43 44 45 |
# File 'lib/jsondb/result_set.rb', line 42 def like(field, value) @like[field] = value return self end |
#max(field, value) ⇒ Object
31 32 33 34 |
# File 'lib/jsondb/result_set.rb', line 31 def max(field, value) @max[field] = value return self end |
#min(field, value) ⇒ Object
26 27 28 29 |
# File 'lib/jsondb/result_set.rb', line 26 def min(field, value) @min[field] = value return self end |
#result ⇒ Object
TODO: For next version TODO: Change it, it must compare all records at the same time all_records.each do |r|
eq.each do |k,v|
ok if match
ok_array << ok
end
if ok_Array.all == true then it match
56 57 58 59 60 61 62 |
# File 'lib/jsondb/result_set.rb', line 56 def result eq = result_equal if @equal.keys.count != 0 min = result_min if @min.keys.count != 0 max = result_max if @max.keys.count != 0 like = result_like if @like.keys.count != 0 return @result end |