Sha256: 4e7899e2e0e26cca71da97124d28249c9219f37b8898af5e929324813225eeb0

Contents?: true

Size: 823 Bytes

Versions: 21

Compression:

Stored size: 823 Bytes

Contents

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module Array #:nodoc:
      # Makes it easier to access parts of an array.
      module Access
        # Returns the remaining of the array from the +position+.
        #
        # Examples: 
        #   %w( a b c d ).from(0)  # => %w( a b c d )
        #   %w( a b c d ).from(2)  # => %w( c d )
        #   %w( a b c d ).from(10) # => nil
        def from(position)
          self[position..-1]
        end
        
        # Returns the beginning of the array up to the +position+.
        #
        # Examples: 
        #   %w( a b c d ).to(0)  # => %w( a )
        #   %w( a b c d ).to(2)  # => %w( a b c )
        #   %w( a b c d ).to(10) # => %w( a b c d )
        def to(position)
          self[0..position]
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
activesupport-2.0.1 lib/active_support/core_ext/array/access.rb
activesupport-2.0.0 lib/active_support/core_ext/array/access.rb
activesupport-2.0.5 lib/active_support/core_ext/array/access.rb
activesupport-2.0.2 lib/active_support/core_ext/array/access.rb
activesupport-2.0.4 lib/active_support/core_ext/array/access.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb
swivel-0.0.175 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb
swivel-0.0.157 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/array/access.rb