Module: Mongoid::Criteria::Queryable::Extensions::Numeric

Defined in:
build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/numeric.rb

Overview

This module contains additional numeric behavior.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#__evolve_date__Time

Evolve the numeric value into a mongo friendly date, aka UTC time at midnight.

Examples:

Evolve to a date.

125214512412.1123.__evolve_date__

Returns:

  • (Time)

    The time representation at UTC midnight.

Since:

  • 1.0.0



21
22
23
24
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/numeric.rb', line 21

def __evolve_date__
  time = ::Time.at(self).utc
  ::Time.utc(time.year, time.month, time.day, 0, 0, 0, 0)
end

#__evolve_time__Time

Evolve the numeric value into a mongo friendly time.

Examples:

Evolve to a time.

125214512412.1123.__evolve_time__

Returns:

  • (Time)

    The time representation.

Since:

  • 1.0.0



34
35
36
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/numeric.rb', line 34

def __evolve_time__
  ::Time.at(self).utc
end

#to_directionInteger

Get the integer as a sort direction.

Examples:

Get the integer as a sort direction.

1.to_direction

Returns:

  • (Integer)

    self.

Since:

  • 1.0.0



46
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/numeric.rb', line 46

def to_direction; self; end