Class: PyCall::IterableWrapper
- Inherits:
-
Object
- Object
- PyCall::IterableWrapper
- Includes:
- Enumerable
- Defined in:
- lib/pycall/iterable_wrapper.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(obj) ⇒ IterableWrapper
constructor
A new instance of IterableWrapper.
Constructor Details
#initialize(obj) ⇒ IterableWrapper
Returns a new instance of IterableWrapper.
5 6 7 |
# File 'lib/pycall/iterable_wrapper.rb', line 5 def initialize(obj) @obj = check_iterable(obj) end |
Instance Method Details
#each ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pycall/iterable_wrapper.rb', line 16 def each return enum_for(__method__) unless block_given? iter = @obj.__iter__() while true begin yield iter.__next__() rescue PyCall::PyError => err if err.type == PyCall.builtins.StopIteration break else raise err end end end end |