Class: LibBEL::BelTokenIterator
- Inherits:
-
FFI::ManagedStruct
- Object
- FFI::ManagedStruct
- LibBEL::BelTokenIterator
- Includes:
- Enumerable
- Defined in:
- lib/bel/libbel/bel_token_iterator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.release(ptr) ⇒ Object
26 27 28 |
# File 'lib/bel/libbel/bel_token_iterator.rb', line 26 def self.release(ptr) LibBEL::free_bel_token_iterator(ptr) end |
Instance Method Details
#each ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bel/libbel/bel_token_iterator.rb', line 10 def each if self.null? or not LibBEL::bel_token_iterator_end(self).zero? fail StopIteration, "bel_token_iterator reached end" end if block_given? while LibBEL::bel_token_iterator_end(self.pointer).zero? current_token = LibBEL::bel_token_iterator_get(self.pointer) yield LibBEL::BelToken.new(current_token) LibBEL::bel_token_iterator_next(self.pointer) end else enum_for(:each) end end |