Class: Time
Class Method Summary collapse
-
.since(t) ⇒ Float
Returns the number of seconds since
t. -
.until(t) ⇒ Float
Returns the number of seconds until
t.
Instance Method Summary collapse
-
#from_now ⇒ Float
Returns the number of seconds until the time represented by this Time object.
-
#to_now ⇒ Float
Returns the number of seconds since the time represented by this Time object.
Class Method Details
.since(t) ⇒ Float
Returns the number of seconds since t
61 62 63 |
# File 'lib/mug/time.rb', line 61 def since t t.to_now end |
.until(t) ⇒ Float
Returns the number of seconds until t
51 52 53 |
# File 'lib/mug/time.rb', line 51 def until t t.from_now end |
Instance Method Details
#from_now ⇒ Float
Returns the number of seconds until the time represented by this Time object.
35 36 37 38 39 40 41 |
# File 'lib/mug/time.rb', line 35 def from_now #if time.respond_to? :unix_timestamp # to_i - Time.unix_timestamp #else self - self.class.now #end end |
#to_now ⇒ Float
Returns the number of seconds since the time represented by this Time object.
16 17 18 19 20 21 22 |
# File 'lib/mug/time.rb', line 16 def to_now #if Time.respond_to? :unix_timestamp # Time.unix_timestamp - to_i #else self.class.now - self #end end |