Class: SimpleSshBackup::Config
- Inherits:
-
Object
- Object
- SimpleSshBackup::Config
- Defined in:
- lib/simple_ssh_backup/config.rb
Instance Attribute Summary collapse
-
#backup_dir ⇒ Object
readonly
Returns the value of attribute backup_dir.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(config_file) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 |
# File 'lib/simple_ssh_backup/config.rb', line 8 def initialize @targets = nil @backup_dir = nil end |
Instance Attribute Details
#backup_dir ⇒ Object (readonly)
Returns the value of attribute backup_dir.
6 7 8 |
# File 'lib/simple_ssh_backup/config.rb', line 6 def backup_dir @backup_dir end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
6 7 8 |
# File 'lib/simple_ssh_backup/config.rb', line 6 def targets @targets end |
Instance Method Details
#load(config_file) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/simple_ssh_backup/config.rb', line 13 def load(config_file) raise ArgumentError, 'Config file does not exist' unless File.exists?(config_file) raise ArgumentError, 'Config not readable' unless File.readable?(config_file) file_contents = File.read(config_file) props = YAML.load(file_contents) @backup_dir = props['backup_dir'] @targets = props['targets'] end |