Module: Origin::Extensions::Range

Defined in:
lib/origin/extensions/range.rb

Overview

This module contains additional range behaviour.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#__array__Array

Get the range as an array.

Examples:

Get the range as an array.

1...3.__array__

Returns:

  • (Array)

    The range as an array.

Since:

  • 1.0.0



16
17
18
# File 'lib/origin/extensions/range.rb', line 16

def __array__
  to_a
end

#__evolve_date__Hash

Convert the range to a min/max mongo friendly query for dates.

Examples:

Evolve the range.

(11231312..213123131).__evolve_date__

Returns:

  • (Hash)

    The min/max range query with times at midnight.

Since:

  • 1.0.0



28
29
30
# File 'lib/origin/extensions/range.rb', line 28

def __evolve_date__
  { "$gte" => min.__evolve_date__, "$lte" => max.__evolve_date__ }
end

#__evolve_time__Hash

Convert the range to a min/max mongo friendly query for times.

Examples:

Evolve the range.

(11231312..213123131).__evolve_date__

Returns:

  • (Hash)

    The min/max range query with times.

Since:

  • 1.0.0



40
41
42
# File 'lib/origin/extensions/range.rb', line 40

def __evolve_time__
  { "$gte" => min.__evolve_time__, "$lte" => max.__evolve_time__ }
end