Class: PyCall::List
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #each(&block) ⇒ Object
- #include?(item) ⇒ Boolean
- #length ⇒ Object
- #push(*items) ⇒ Object
- #sort ⇒ Object
- #sort! ⇒ Object
- #to_a ⇒ Object (also: #to_ary)
Instance Method Details
#<<(item) ⇒ Object
22 23 24 |
# File 'lib/pycall/list.rb', line 22 def <<(item) append(item) end |
#each(&block) ⇒ Object
16 17 18 19 20 |
# File 'lib/pycall/list.rb', line 16 def each(&block) return enum_for unless block_given? LibPython::Helpers.sequence_each(__pyptr__, &block) self end |
#include?(item) ⇒ Boolean
8 9 10 |
# File 'lib/pycall/list.rb', line 8 def include?(item) LibPython::Helpers.sequence_contains(__pyptr__, item) end |
#push(*items) ⇒ Object
26 27 28 |
# File 'lib/pycall/list.rb', line 26 def push(*items) items.each {|i| append(i) } end |
#sort ⇒ Object
30 31 32 |
# File 'lib/pycall/list.rb', line 30 def sort dup.sort! end |
#sort! ⇒ Object
34 35 36 37 |
# File 'lib/pycall/list.rb', line 34 def sort! LibPython::Helpers.getattr(__pyptr__, :sort).__call__ self end |
#to_a ⇒ Object Also known as: to_ary
39 40 41 |
# File 'lib/pycall/list.rb', line 39 def to_a Array.new(length) {|i| self[i] } end |