Class: NSIndexPath
- Defined in:
- lib/cocoa/sugarcube-to_s/nsindexpath.rb,
lib/cocoa/sugarcube-foundation/nsindexpath.rb
Instance Method Summary collapse
-
#to_a ⇒ Object
convert to an array of integers.
-
#to_ary ⇒ Object
support multiple assignment.
- #to_s ⇒ Object
Instance Method Details
#to_a ⇒ Object
convert to an array of integers
example:
path = NSIndexPath.indexPathWithIndex(1).indexPathByAddingIndex(3)
path.to_a # => [1, 3]
18 19 20 21 22 |
# File 'lib/cocoa/sugarcube-foundation/nsindexpath.rb', line 18 def to_a self.length.times.reduce([]) do |a, i| a << self.indexAtPosition(i) end end |
#to_ary ⇒ Object
support multiple assignment
example:
a, b = NSIndexPath.indexPathWithIndex(1).indexPathByAddingIndex(3)
a # => 1
b # => 3
9 10 11 |
# File 'lib/cocoa/sugarcube-foundation/nsindexpath.rb', line 9 def to_ary to_a end |
#to_s ⇒ Object
3 4 5 6 7 |
# File 'lib/cocoa/sugarcube-to_s/nsindexpath.rb', line 3 def to_s return super unless self.respond_to?(:to_a) "<NSIndexPath #{to_a.to_s}>" end |