1.minute 和 1.hour 、1.month 是什么意思?

It's a little trick that Rails adds to Ruby

 

 

1、切换到 rails console 下

2、运行:

1.hour => 3600 seconds
1.hour.class => Fixnum

 

+++++++++++++++++++++++++++++++++++++++++++

 

E:\awe\awe-source-code\awe-server-code\awe-server\awe>rails console
Loading development environment (Rails 3.0.9)
irb(main):001:0> 1.hour
=> 3600 seconds
irb(main):002:0> 1.hour.class
=> Fixnum
irb(main):003:0> 1.minute
=> 60 seconds

 

++++++++++++++++++++++++++++++++++++++++++++

 

irb(main):014:0> 1.hour.from_now
=> Mon, 10 Oct 2011 09:00:41 UTC +00:00
irb(main):015:0> 1.hour.from_now.class
=> ActiveSupport::TimeWithZone
irb(main):016:0>

 

你可能感兴趣的:(in)