Class: Time
- Defined in:
- lib/backports/2.7.0/time/ceil.rb,
lib/backports/2.7.0/time/floor.rb
Instance Method Summary collapse
Instance Method Details
#ceil(ndigits = 0) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/backports/2.7.0/time/ceil.rb', line 3 def ceil(ndigits = 0) # Imitate value.ceil(ndigits) which does not exist in Ruby < 2.4 sceil = (subsec * 10**ndigits).ceil.to_r / 10**ndigits change = sceil - subsec self + change end |
#floor(ndigits = 0) ⇒ Object
3 4 5 |
# File 'lib/backports/2.7.0/time/floor.rb', line 3 def floor(ndigits = 0) self - subsec.modulo(10**-ndigits) end |