to_r
is a Ruby attribute that is invoked by a time object. It returns the value of a time object as a rational number of seconds since the Epoch.
timeObj.to_r
What is returned is the value of the time object timeObj
as a rational number of seconds since the Epoch.
# create time objectst1 = Time.now # current timet2 = Time.at(946702800)t3 = Time.new(2021)# get seconds since unix epoch# as rational number# and print resultsputs t1.to_rputs t2.to_rputs t3.to_r
to_r
attribute and printed to the console.RELATED TAGS
CONTRIBUTOR