Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/ecraft/extensions/time.rb
Instance Method Summary collapse
Instance Method Details
#as_ms ⇒ Object
5 6 7 |
# File 'lib/ecraft/extensions/time.rb', line 5 def as_ms to_i * 1000 + usec / 1000 end |
#to_json(*_a) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/ecraft/extensions/time.rb', line 9 def to_json(*_a) # Use the precision provided in our receiver, but only up to milliseconds at max. Objects lacking the fraction part # altogether will be serialized without fraction part using this algorithm. fraction_digits = [nsec.to_s.sub(/0+$/, '').length, 3].min iso8601(fraction_digits).to_json end |