On Dec 21, 10:07 pm, Peter Vandenabeele <li...@ruby-forum.com> wrote:
> Frederick Cheung wrote in post #969871:

>
> I am actually curious how I could see from the object
> itself in a Rails context that it's not "really" a Fixnum,
> but an ActiveSupport::Duration object

ActiveSupport::Duration === foo would return true (or Fixnum === foo
would return false)


> Also, here I did use specific units (in-casu "days"),
> but still I had naively expected a different result
> on line 005.
>
> 004:0> weekend.seconds
> => 172800 seconds # this is correct
> 005:0> weekend.days
> => 172800 days # I had expected '2' or '2 days'

a Duration object doesn't have days (or seconds etc.) methods that
return the invidual components (the parts method does that), so when
you call days on it, it ends up calling days on its value in seconds.

>
> Thanks,
>
> Peter
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to