模块:Mongoid::Extensions::Float

定义于:
lib/mongoid/extensions/float.rb

Overview

为 Float 类添加类型转换行为。

在命名空间下定义

模块: 类方法

实例方法摘要折叠

实例方法详细信息

# __mongoize_time__时间| ActiveSupport::TimeWithZone

将浮点数转换为时间,即自纪元以来的秒数。

例子:

将浮点数转换为时间。

1335532685.117847.__mongoize_time__

返回:

  • ( Time | ActiveSupport::TimeWithZone )

    时间。



16
17
18
# File 'lib/mongoid/extensions/float.rb', line 16

def __mongoize_time__
  ::时间.区域.at(self)
end

# numeric?true

浮点数是数字吗?

例子:

对象是数字吗?

object.numeric?

返回:

  • ( true )

    始终为 true。



26
27
28
# File 'lib/mongoid/extensions/float.rb', line 26

def numeric?
  true
end