Class: Cassandra::Time
- Inherits:
-
Object
- Object
- Cassandra::Time
- Includes:
- Comparable
- Defined in:
- lib/cassandra/time.rb
Overview
Represents a Cassandra time type.
Instance Method Summary collapse
-
#hours ⇒ Integer
An integer between 0 and 24, the number of full hours since midnight that this time represents.
-
#miliseconds ⇒ Integer
An integer between 0 and 60, the number of full miliseconds since the last full second that this time represents.
-
#minutes ⇒ Integer
An integer between 0 and 60, the number of full minutes since the last full hour that this time represents.
-
#seconds ⇒ Integer
An integer between 0 and 60, the number of full seconds since the last full minutes that this time represents.
-
#to_nanoseconds ⇒ Integer
An integer between 0 and 86400000000000, the number of nanoseconds since midnight that this time represents.
-
#to_s ⇒ String
A "%H:%M%S.%3N" formatted time string.
Instance Method Details
#hours ⇒ Integer
Returns an integer between 0 and 24, the number of full hours since midnight that this time represents.
47 48 49 |
# File 'lib/cassandra/time.rb', line 47 def hours @nanoseconds / NANOSECONDS_IN_HOUR end |
#miliseconds ⇒ Integer
Returns an integer between 0 and 60, the number of full miliseconds since the last full second that this time represents.
67 68 69 70 71 72 |
# File 'lib/cassandra/time.rb', line 67 def miliseconds (@nanoseconds - (hours * NANOSECONDS_IN_HOUR) - (minutes * NANOSECONDS_IN_MINUTE) - (seconds * NANOSECONDS_IN_SECOND)) / NANOSECONDS_IN_MILISECOND end |
#minutes ⇒ Integer
Returns an integer between 0 and 60, the number of full minutes since the last full hour that this time represents.
53 54 55 |
# File 'lib/cassandra/time.rb', line 53 def minutes (@nanoseconds - (hours * NANOSECONDS_IN_HOUR)) / NANOSECONDS_IN_MINUTE end |
#seconds ⇒ Integer
Returns an integer between 0 and 60, the number of full seconds since the last full minutes that this time represents.
59 60 61 62 63 |
# File 'lib/cassandra/time.rb', line 59 def seconds (@nanoseconds - (hours * NANOSECONDS_IN_HOUR) - (minutes * NANOSECONDS_IN_MINUTE)) / NANOSECONDS_IN_SECOND end |
#to_nanoseconds ⇒ Integer
Returns an integer between 0 and 86400000000000, the number of nanoseconds since midnight that this time represents.
81 82 83 |
# File 'lib/cassandra/time.rb', line 81 def to_nanoseconds @nanoseconds end |
#to_s ⇒ String
Returns a "%H:%M%S.%3N" formatted time string.
75 76 77 |
# File 'lib/cassandra/time.rb', line 75 def to_s format('%.2d:%.2d:%.2d.%.3d', hours, minutes, seconds, miliseconds) end |