Class: Traildb::TrailDBCursor
- Inherits:
-
FFI::AutoPointer
- Object
- FFI::AutoPointer
- Traildb::TrailDBCursor
- Includes:
- Enumerable
- Defined in:
- lib/traildb.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(cursor, cls, valuefun, parsetime, only_timestamp, event_filter_obj) ⇒ TrailDBCursor
constructor
A new instance of TrailDBCursor.
Constructor Details
#initialize(cursor, cls, valuefun, parsetime, only_timestamp, event_filter_obj) ⇒ TrailDBCursor
Returns a new instance of TrailDBCursor.
183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/traildb.rb', line 183 def initialize(cursor, cls, valuefun, parsetime, , event_filter_obj) super cursor @cls = cls @valuefun = valuefun @parsetime = parsetime @only_timestamp = if event_filter_obj @event_filter_obj = event_filter_obj ret = Traildb.tdb_cursor_set_event_filter(self, event_filter_obj) raise TrailDBError.new("cursor_set_event_filter failed", ret) if ret != 0 end end |
Class Method Details
.release(ptr) ⇒ Object
211 212 213 |
# File 'lib/traildb.rb', line 211 def self.release(ptr) Trailsdb.tdb_cursor_free(ptr) end |
Instance Method Details
#each ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/traildb.rb', line 196 def each loop do event = Traildb.tdb_cursor_next(self) break if event.null? = event[:timestamp] = Time.at() if @parsetime if @only_timestamp yield else items = event.tdb_items(@valuefun) yield @cls.new(, *items) end end end |