Class: OsCtld::RunState::StartConfig
- Inherits:
-
Object
- Object
- OsCtld::RunState::StartConfig
- Defined in:
- lib/osctld/run_state/start_config.rb
Overview
One-time config for osctld
Instance Attribute Summary collapse
-
#cfg ⇒ Object
readonly
protected
Returns the value of attribute cfg.
- #path ⇒ String readonly
Instance Method Summary collapse
- #close ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(path) ⇒ StartConfig
constructor
A new instance of StartConfig.
- #open_config ⇒ Object protected
Constructor Details
#initialize(path) ⇒ StartConfig
Returns a new instance of StartConfig.
10 11 12 13 |
# File 'lib/osctld/run_state/start_config.rb', line 10 def initialize(path) @path = path open_config end |
Instance Attribute Details
#cfg ⇒ Object (readonly, protected)
Returns the value of attribute cfg.
27 28 29 |
# File 'lib/osctld/run_state/start_config.rb', line 27 def cfg @cfg end |
#path ⇒ String (readonly)
7 8 9 |
# File 'lib/osctld/run_state/start_config.rb', line 7 def path @path end |
Instance Method Details
#close ⇒ Object
19 20 21 22 23 |
# File 'lib/osctld/run_state/start_config.rb', line 19 def close File.unlink(path) if exist? rescue Errno::ENOENT # ignore end |
#exist? ⇒ Boolean
15 16 17 |
# File 'lib/osctld/run_state/start_config.rb', line 15 def exist? @exist end |
#open_config ⇒ Object (protected)
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/osctld/run_state/start_config.rb', line 29 def open_config @cfg = {} begin data = File.read(path) rescue Errno::ENOENT @exist = false return end @exist = true @cfg = JSON.parse(data) end |