Module: Droonga::Timestamp
- Defined in:
- lib/droonga/timestamp.rb
Constant Summary collapse
- MICRO_SECONDS_DECIMAL_PLACE =
6
Class Method Summary collapse
- .last_message_timestamp ⇒ Object
- .last_message_timestamp=(timestamp) ⇒ Object
- .run_last_message_timestamp_observer(loop, &block) ⇒ Object
- .stringify(timestamp) ⇒ Object
Class Method Details
.last_message_timestamp ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/droonga/timestamp.rb', line 50 def file = Path. return nil unless file.exist? = file.read.strip return nil if .nil? or .empty? Time.parse() end |
.last_message_timestamp=(timestamp) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/droonga/timestamp.rb', line 31 def () if .is_a?(String) = .strip if .empty? = nil else = Time.parse() end end if = stringify() else = "" end SafeFileWriter.write(Path.) do |output, file| output.puts() end end |
.run_last_message_timestamp_observer(loop, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/droonga/timestamp.rb', line 58 def (loop, &block) path = Path. observer = FileObserver.new(loop, path) observer.on_change = lambda do yield() end observer.start observer end |
.stringify(timestamp) ⇒ Object
27 28 29 |
# File 'lib/droonga/timestamp.rb', line 27 def stringify() .utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE) end |