Class: Knowledge::Backupper
- Inherits:
-
Object
- Object
- Knowledge::Backupper
- Defined in:
- lib/knowledge/backupper.rb
Overview
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Configuration hash.
-
#path ⇒ Object
readonly
Backup file path.
Instance Method Summary collapse
-
#backup! ⇒ Object
Backups the configuration.
-
#initialize(path:) ⇒ Backupper
constructor
Just sets the basic configuration object.
-
#set(name:, value:) ⇒ Object
(also: #register)
Sets the variable before backuping everything.
Constructor Details
#initialize(path:) ⇒ Backupper
Just sets the basic configuration object.
Parameters
47 48 49 50 |
# File 'lib/knowledge/backupper.rb', line 47 def initialize(path:) @configuration = {} @path = path end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Configuration hash
29 30 31 |
# File 'lib/knowledge/backupper.rb', line 29 def configuration @configuration end |
#path ⇒ Object (readonly)
Backup file path
29 30 31 |
# File 'lib/knowledge/backupper.rb', line 29 def path @path end |
Instance Method Details
#backup! ⇒ Object
Backups the configuration.
57 58 59 60 61 62 63 |
# File 'lib/knowledge/backupper.rb', line 57 def backup! f = File.new(path, 'w') f.write(configuration.to_yaml) f.close end |
#set(name:, value:) ⇒ Object Also known as: register
Sets the variable before backuping everything.
Parameters
73 74 75 |
# File 'lib/knowledge/backupper.rb', line 73 def set(name:, value:) configuration[name.to_sym] = value end |