Class: Textus::CursorStore
- Inherits:
-
Object
- Object
- Textus::CursorStore
- Defined in:
- lib/textus/cursor_store.rb
Overview
Per-role cursor cache under <root>/.run/state/cursor.<role>. A convenience so ‘textus pulse` (no –since) means “since I last looked”. Gitignored; losing it just re-emits recent deltas, never corrupts the store. ADR 0036/0038.
Instance Method Summary collapse
-
#initialize(root:, role:) ⇒ CursorStore
constructor
A new instance of CursorStore.
- #read ⇒ Object
- #write(seq) ⇒ Object
Constructor Details
#initialize(root:, role:) ⇒ CursorStore
Returns a new instance of CursorStore.
8 9 10 |
# File 'lib/textus/cursor_store.rb', line 8 def initialize(root:, role:) @path = Textus::Layout.cursor(root, role) end |
Instance Method Details
#read ⇒ Object
12 13 14 15 16 |
# File 'lib/textus/cursor_store.rb', line 12 def read Integer(File.read(@path).strip) rescue Errno::ENOENT, ArgumentError 0 end |
#write(seq) ⇒ Object
18 19 20 21 22 |
# File 'lib/textus/cursor_store.rb', line 18 def write(seq) FileUtils.mkdir_p(File.dirname(@path)) File.write(@path, seq.to_s) seq end |