Class: VinaryTree::Libdictenstein::EntryStream
- Inherits:
-
Object
- Object
- VinaryTree::Libdictenstein::EntryStream
- Includes:
- Enumerable
- Defined in:
- lib/vinary_tree/libdictenstein.rb
Overview
Public bounded stream. Enumerable#each uses ensure so break and raised exceptions deterministically close the native cursor.
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Class Method Summary collapse
Instance Method Summary collapse
- #cancel ⇒ Object
- #close ⇒ Object
- #each ⇒ Object
-
#initialize(handle, max_entries:, max_units:, max_values:) ⇒ EntryStream
constructor
A new instance of EntryStream.
- #next ⇒ Object
Constructor Details
#initialize(handle, max_entries:, max_units:, max_values:) ⇒ EntryStream
Returns a new instance of EntryStream.
245 246 247 248 249 250 251 252 253 254 |
# File 'lib/vinary_tree/libdictenstein.rb', line 245 def initialize(handle, max_entries:, max_units:, max_values:) @state = EntryCursorState.new( handle, max_entries: max_entries, max_units: max_units, max_values: max_values ) @info = @state.info ObjectSpace.define_finalizer(self, self.class.finalizer(@state)) end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
243 244 245 |
# File 'lib/vinary_tree/libdictenstein.rb', line 243 def info @info end |
Class Method Details
.finalizer(state) ⇒ Object
256 |
# File 'lib/vinary_tree/libdictenstein.rb', line 256 def self.finalizer(state) = proc { state.close rescue nil } |
Instance Method Details
#cancel ⇒ Object
272 |
# File 'lib/vinary_tree/libdictenstein.rb', line 272 def cancel = @state.cancel |
#close ⇒ Object
274 275 276 277 278 |
# File 'lib/vinary_tree/libdictenstein.rb', line 274 def close @state.close ObjectSpace.undefine_finalizer(self) if @state.closed? nil end |
#each ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/vinary_tree/libdictenstein.rb', line 260 def each return enum_for(__method__) unless block_given? begin while (entry = self.next) yield entry end ensure close end self end |
#next ⇒ Object
258 |
# File 'lib/vinary_tree/libdictenstein.rb', line 258 def next = @state.next_entry |