class PyCall::IterableWrapper
Public Class Methods
new(obj)
click to toggle source
# File lib/pycall/iterable_wrapper.rb, line 5 def initialize(obj) @obj = check_iterable(obj) end
Public Instance Methods
each() { |__next__| ... }
click to toggle source
# 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
Private Instance Methods
check_iterable(obj)
click to toggle source
# File lib/pycall/iterable_wrapper.rb, line 9 def check_iterable(obj) unless PyCall.hasattr?(obj, :__iter__) raise ArgumentError, "%p object is not iterable" % obj end obj end