Sha256: 37b0702883fbe95f5b641ad7018a5e1944382953434ee010eacdc8b9295f3c00

Contents?: true

Size: 694 Bytes

Versions: 14

Compression:

Stored size: 694 Bytes

Contents

class Array
  # Returns the tail of the array from +position+.
  #
  #   %w( a b c d ).from(0)  # => ["a", "b", "c", "d"]
  #   %w( a b c d ).from(2)  # => ["c", "d"]
  #   %w( a b c d ).from(10) # => []
  #   %w().from(0)           # => []
  def from(position)
    self[position, length] || []
  end

  # Returns the beginning of the array up to +position+.
  #
  #   %w( a b c d ).to(0)  # => ["a"]
  #   %w( a b c d ).to(2)  # => ["a", "b", "c"]
  #   %w( a b c d ).to(10) # => ["a", "b", "c", "d"]
  #   %w().to(0)           # => []
  def to(position)
    first position + 1
  end

  # Equal to <tt>self[1]</tt>.
  #
  #   %w( a b c d e ).second # => "b"
  def second
    self[1]
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
motion-support-1.2.1 motion/core_ext/array/access.rb
motion-support-1.1.1 motion/core_ext/array/access.rb
motion-support-1.2.0 motion/core_ext/array/access.rb
motion-support-1.1.0 motion/core_ext/array/access.rb
motion-support-1.0.0 motion/core_ext/array/access.rb
motion-support-0.3.0 motion/core_ext/array/access.rb
motion_blender-support-0.2.8 motion/core_ext/array/access.rb
motion_blender-support-0.2.7 motion/core_ext/array/access.rb
motion-support-0.2.6 motion/core_ext/array/access.rb
motion-support-0.2.5 motion/core_ext/array/access.rb
motion-support-0.2.4 motion/core_ext/array/access.rb
motion-support-0.2.3 motion/core_ext/array/access.rb
motion-support-0.2.2 motion/core_ext/array/access.rb
motion-support-0.2.0 motion/core_ext/array/access.rb