Sha256: a81c7667fd6fb001b8ab7bcf99ff2b67b03b30cf4ebc2772dcfc5a89d2654d00

Contents?: true

Size: 768 Bytes

Versions: 25

Compression:

Stored size: 768 Bytes

Contents

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module Array #:nodoc:
      # Makes it easier to access parts of an array.
      module Access
        # Returns the tail of the array from +position+.
        #
        #   %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 +position+.
        #
        #   %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

25 entries across 25 versions & 7 rubygems

Version Path
3mix-castronaut-0.5.0.2 vendor/activesupport/lib/active_support/core_ext/array/access.rb
masover-castronaut-0.4.4.4 vendor/activesupport/lib/active_support/core_ext/array/access.rb
masover-castronaut-0.4.4.5 vendor/activesupport/lib/active_support/core_ext/array/access.rb
masover-castronaut-0.5.0.1 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.4.1 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.4.2 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.4.3 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.4.4 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.4.5 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.4.6 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.5.0 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.5.1 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.5.2 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.5.3 vendor/activesupport/lib/active_support/core_ext/array/access.rb
relevance-castronaut-0.5.4 vendor/activesupport/lib/active_support/core_ext/array/access.rb
radiant-0.7.2 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
activesupport-2.1.0 lib/active_support/core_ext/array/access.rb
activesupport-2.1.2 lib/active_support/core_ext/array/access.rb