1 module ActiveSupport
#:nodoc:
2 module CoreExtensions
#:nodoc:
4 # Getting ranges in different convenient string representations and other objects
7 :db => Proc
.new
{ |start
, stop
| "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" }
10 def self.included(base
) #:nodoc:
12 alias_method
:to_default_s, :to_s
13 alias_method
:to_s, :to_formatted_s
16 # Gives a human readable format of the range.
20 # [1..100].to_formatted_s # => "1..100"
21 def to_formatted_s(format
= :default)
22 RANGE_FORMATS
[format
] ? RANGE_FORMATS
[format
].call(first
, last
) : to_default_s