Sha256: 5b10f1f90f954eb3be350047e19ef4c63dce788215683f7b9f77f9feb0319e08
Contents?: true
Size: 948 Bytes
Versions: 1
Compression:
Stored size: 948 Bytes
Contents
module PyCall class Tuple include PyObjectWrapper def self.new(init) case init when Integer super(LibPython.PyTuple_New(init)) when Array tuple = new(init.length) init.each_with_index do |obj, index| tuple[index] = obj end tuple when LibPython::PyObjectStruct super(init) end end # Make tuple from array def self.[](*ary) new(ary) end def size LibPython.PyTuple_Size(__pyobj__) end alias length size def [](index) LibPython.PyTuple_GetItem(__pyobj__, index).to_ruby end def []=(index, value) value = Conversions.from_ruby(value) LibPython.PyTuple_SetItem(__pyobj__, index, value) end def to_a [].tap do |ary| i, n = 0, length while i < n ary << self[i] i += 1 end end end alias to_ary to_a end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pycall-0.1.0.alpha.20170711 | lib/pycall/tuple.rb |