Sha256: 1aa7889dc00b491e5300f05b76cb6dcf5b7be904a3341343196c6254823adfc0

Contents?: true

Size: 722 Bytes

Versions: 6

Compression:

Stored size: 722 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(&block)
      return enum_for unless block_given?
      LibPython::Helpers.sequence_each(__pyptr__, &block)
      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

6 entries across 6 versions & 1 rubygems

Version Path
pycall-1.5.1 lib/pycall/list.rb
pycall-1.5.0 lib/pycall/list.rb
pycall-1.4.2 lib/pycall/list.rb
pycall-1.4.1 lib/pycall/list.rb
pycall-1.4.0 lib/pycall/list.rb
pycall-1.3.1 lib/pycall/list.rb