lib/pycall/slice.rb in pycall-0.1.0.alpha.20170711 vs lib/pycall/slice.rb in pycall-1.0.0
- old
+ new
@@ -1,27 +1,8 @@
module PyCall
+ Slice = builtins.slice
class Slice
- include PyObjectWrapper
-
- def self.new(*args)
- start, stop, step = nil
- case args.length
- when 1
- stop = args[0]
- return super(stop) if stop.kind_of?(LibPython::PyObjectStruct)
- when 2
- start, stop = args
- when 3
- start, stop, step = args
- else
- much_or_few = args.length > 3 ? 'much' : 'few'
- raise ArgumentError, "too #{much_or_few} arguments (#{args.length} for 1..3)"
- end
- start = start ? Conversions.from_ruby(start) : LibPython::PyObjectStruct.null
- stop = stop ? Conversions.from_ruby(stop) : LibPython::PyObjectStruct.null
- step = step ? Conversions.from_ruby(step) : LibPython::PyObjectStruct.null
- pyobj = LibPython.PySlice_New(start, stop, step)
- return pyobj.to_ruby unless pyobj.null?
- raise PyError.fetch
+ def self.all
+ new(nil)
end
end
end