Sha256: 309b8ed58fa913f597519d1305dd99fc8babe12536a511d405b96ee2c54f10b5

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 Bytes

Contents

module PyBind
  class PySlice
    include PyObjectWrapper
    pybind_type LibPython.PySlice_Type

    def self.new(start, stop = nil, step = nil)
      if stop.nil? && step.nil?
        start, stop = nil, start
        return super(stop) if stop.kind_of?(PyObjectStruct)
      end
      start = start ? start.to_python : PyObjectStruct.null
      stop = stop ? stop.to_python : PyObjectStruct.null
      step = step ? step.to_python : PyObjectStruct.null
      pyobj = LibPython.PySlice_New(start, stop, step)
      raise PyError.fetch if pyobj.null?
      pyobj.to_ruby
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pybind-0.1.0 lib/pybind/types/slice.rb