Sha256: c6b1cc8af00f6d0ce0934f56123be81598dcac3522726112865a7a4704d95bfe

Contents?: true

Size: 475 Bytes

Versions: 28

Compression:

Stored size: 475 Bytes

Contents

class NSIndexPath

  # support multiple assignment
  #
  # example:
  #     a, b = NSIndexPath.indexPathWithIndex(1).indexPathByAddingIndex(3)
  #     a  # => 1
  #     b  # => 3
  def to_ary
    to_a
  end

  # convert to an array of integers
  #
  # example:
  #     path = NSIndexPath.indexPathWithIndex(1).indexPathByAddingIndex(3)
  #     path.to_a  # => [1, 3]
  def to_a
    self.length.times.reduce([]) do |a, i|
      a << self.indexAtPosition(i)
    end
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sugarcube-3.0.4 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.3 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.2 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.1 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-2.12.3 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-2.12.2 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-2.12.1 lib/cocoa/sugarcube-foundation/nsindexpath.rb