Sha256: 1c910e4f2a1ec6bfba3c4899978a821a07a63521ff5e96ba31fb264ff22fe9b6
Contents?: true
Size: 504 Bytes
Versions: 1
Compression:
Stored size: 504 Bytes
Contents
class Array # Returns the index range between two elements. # If no elements are given, returns the range # from first to last. # # require 'facet/array/range' # # ['a','b','c','d'].range #=> 0..3 # ['a','b','c','d'].range('b','d') #=> 1..2 # #-- # This could surely use a little error catching code (todo). #++ def range(a=nil,z=nil) if !a 0..self.length-1 else index(a)..index(z) end end alias_method( :index_range, :range ) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-0.6.3 | lib/facet/array/range.rb |