Sha256: c3edd9340dfe075017cbec923aa2c9bbae298e1911b3ae81c87a62ed6d527ee4

Contents?: true

Size: 713 Bytes

Versions: 14

Compression:

Stored size: 713 Bytes

Contents

module PyCall
  List = builtins.list
  class List
    register_python_type_mapping

    include Enumerable

    def include?(item)
      LibPython::Helpers.sequence_contains(__pyptr__, item)
    end

    def length
      PyCall.len(self)
    end

    def each
      return enum_for unless block_given?
      LibPython::Helpers.sequence_each(__pyptr__, &proc)
      self
    end

    def <<(item)
      append(item)
    end

    def push(*items)
      items.each {|i| append(i) }
    end

    def sort
      dup.sort!
    end

    def sort!
      LibPython::Helpers.getattr(__pyptr__, :sort).__call__
      self
    end

    def to_a
      Array.new(length) {|i| self[i] }
    end

    alias to_ary to_a
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pycall-1.3.0 lib/pycall/list.rb
pycall-1.3.0.dev lib/pycall/list.rb
pycall-1.2.1 lib/pycall/list.rb
pycall-1.2.0 lib/pycall/list.rb
pycall-1.2.0.beta1 lib/pycall/list.rb
pycall-1.1.0.rc1 lib/pycall/list.rb
pycall-1.0.3 lib/pycall/list.rb
pycall-1.0.2-x86-mingw32 lib/pycall/list.rb
pycall-1.0.2-x64-mingw32 lib/pycall/list.rb
pycall-1.0.2 lib/pycall/list.rb
pycall-1.0.1-x86-mingw32 lib/pycall/list.rb
pycall-1.0.1-x64-mingw32 lib/pycall/list.rb
pycall-1.0.1 lib/pycall/list.rb
pycall-1.0.0 lib/pycall/list.rb