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-4.0.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.4 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.3 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.2 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.1 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.3.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.2.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.1.1 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.1.0 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.8 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.7 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.6 lib/cocoa/sugarcube-foundation/nsindexpath.rb
sugarcube-3.0.5 lib/cocoa/sugarcube-foundation/nsindexpath.rb