class PyBind::PyList

Public Class Methods

new(init = nil) click to toggle source
Calls superclass method PyBind::PyObjectWrapper::new
# File lib/pybind/types/list.rb, line 10
def self.new(init = nil)
  case init
  when PyObjectStruct
    super
  when nil
    new(0)
  when Integer
    new(LibPython.PyList_New(init))
  when Array
    new.tap do |list|
      init.each do |item|
        list << item
      end
    end
  else
    raise TypeError, "the argument must be an Integer, a PyObjectStruct or a Array"
  end
end

Public Instance Methods

<<(value) click to toggle source
# File lib/pybind/types/list.rb, line 29
def <<(value)
  value = value.to_python
  LibPython.PyList_Append(@pystruct, value)
  self
end
size() click to toggle source
# File lib/pybind/types/list.rb, line 35
def size
  LibPython.PyList_Size(@pystruct)
end