Class: TimeInterval
- Inherits:
-
Object
- Object
- TimeInterval
- Defined in:
- lib/rubko/plugins/db.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#mon ⇒ Object
Returns the value of attribute mon.
-
#usec ⇒ Object
Returns the value of attribute usec.
Instance Method Summary collapse
- #+(time) ⇒ Object
-
#initialize(mon, day, usec) ⇒ TimeInterval
constructor
this class directly adheres to Postgres’s internal INTERVAL representation.
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_json ⇒ Object
- #to_s ⇒ Object
- #to_time ⇒ Object
Constructor Details
#initialize(mon, day, usec) ⇒ TimeInterval
this class directly adheres to Postgres’s internal INTERVAL representation
358 359 360 361 362 |
# File 'lib/rubko/plugins/db.rb', line 358 def initialize(mon, day, usec) @mon = mon @day = day @usec = usec end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
364 365 366 |
# File 'lib/rubko/plugins/db.rb', line 364 def day @day end |
#mon ⇒ Object
Returns the value of attribute mon.
364 365 366 |
# File 'lib/rubko/plugins/db.rb', line 364 def mon @mon end |
#usec ⇒ Object
Returns the value of attribute usec.
364 365 366 |
# File 'lib/rubko/plugins/db.rb', line 364 def usec @usec end |
Instance Method Details
#+(time) ⇒ Object
370 371 372 |
# File 'lib/rubko/plugins/db.rb', line 370 def +(time) ( (time >> mon) + day ).to_time + usec/1_000_000.0 end |
#to_f ⇒ Object
378 379 380 |
# File 'lib/rubko/plugins/db.rb', line 378 def to_f to_time.to_f end |
#to_i ⇒ Object
382 383 384 |
# File 'lib/rubko/plugins/db.rb', line 382 def to_i to_time.to_i end |
#to_json ⇒ Object
386 387 388 |
# File 'lib/rubko/plugins/db.rb', line 386 def to_json(*) to_f.to_s end |
#to_s ⇒ Object
366 367 368 |
# File 'lib/rubko/plugins/db.rb', line 366 def to_s "#{mon}mon #{day}day #{usec}usec" end |
#to_time ⇒ Object
374 375 376 |
# File 'lib/rubko/plugins/db.rb', line 374 def to_time self + DateTime.new(1970) end |