Class: Traildb::TrailDBEventFilter
- Inherits:
-
FFI::AutoPointer
- Object
- FFI::AutoPointer
- Traildb::TrailDBEventFilter
- Defined in:
- lib/traildb.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(db, query) ⇒ TrailDBEventFilter
constructor
A new instance of TrailDBEventFilter.
Constructor Details
#initialize(db, query) ⇒ TrailDBEventFilter
Returns a new instance of TrailDBEventFilter.
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/traildb.rb', line 397 def initialize(db, query) super Traildb.tdb_event_filter_new() if !query[0][0].is_a? Array query = [query] end query.each_with_index do |clause, i| if i > 0 ret = Traildb.tdb_event_filter_new_clause(self) raise TrailDBError.new("Out of memory in create_filter", ret) if ret != 0 end clause.each do |term| ret = 0 if term.size == 2 and term[0].is_a? Integer and term[0].is_a? Integer start_time, end_time = term ret = Traildb.tdb_event_filter_add_time_range(self, start_time, end_time) else is_negative = false if term.size == 3 field, value, is_negative = term else field, value = term end item = begin db.get_item(field, value) rescue TrailDBError, ValueError 0 end ret = Traildb.tdb_event_filter_add_term(self, item, is_negative ? 1 : 0) end raise TrailDBError.new("Out of memory in create_filter", ret) if ret != 0 end end end |
Class Method Details
.release(ptr) ⇒ Object
431 432 433 |
# File 'lib/traildb.rb', line 431 def self.release(ptr) Traildb.tdb_event_filter_free(ptr) end |