Module ActiveSupport::CoreExtensions::Range::Conversions
In: vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb

Getting ranges in different convenient string representations and other objects

Methods

Constants

RANGE_FORMATS = { :db => Proc.new { |start, stop| "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" }

Public Instance methods

Gives a human readable format of the range.

Example

  [1..100].to_formatted_s # => "1..100"

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb, line 21
21:         def to_formatted_s(format = :default)
22:           RANGE_FORMATS[format] ? RANGE_FORMATS[format].call(first, last) : to_default_s
23:         end

[Validate]