Class: GT::State
- Inherits:
-
Object
- Object
- GT::State
- Defined in:
- lib/gt/state.rb
Constant Summary collapse
- FILE_NAME =
"gt-restack-state"
Instance Method Summary collapse
- #active? ⇒ Boolean
- #clear ⇒ Object
-
#initialize ⇒ State
constructor
A new instance of State.
- #load ⇒ Object
- #save(data) ⇒ Object
Constructor Details
Instance Method Details
#active? ⇒ Boolean
13 14 15 |
# File 'lib/gt/state.rb', line 13 def active? File.exist?(@path) end |
#clear ⇒ Object
27 28 29 |
# File 'lib/gt/state.rb', line 27 def clear File.delete(@path) if active? end |
#load ⇒ Object
21 22 23 24 25 |
# File 'lib/gt/state.rb', line 21 def load return nil unless active? JSON.parse(File.read(@path), symbolize_names: true) end |
#save(data) ⇒ Object
17 18 19 |
# File 'lib/gt/state.rb', line 17 def save(data) File.write(@path, JSON.generate(data)) end |