Class: Vagrant::Notify::Data
- Inherits:
-
Object
- Object
- Vagrant::Notify::Data
- Defined in:
- lib/vagrant-notify/data.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(data_dir) ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize(data_dir) ⇒ Data
Returns a new instance of Data.
4 5 6 |
# File 'lib/vagrant-notify/data.rb', line 4 def initialize(data_dir) @data_dir = data_dir end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 20 |
# File 'lib/vagrant-notify/data.rb', line 17 def [](key) file = @data_dir.join(key.to_s) file.read if file.file? end |
#[]=(key, value) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/vagrant-notify/data.rb', line 8 def []=(key, value) file = @data_dir.join(key.to_s) if value.nil? file.delete else file.open("w+") { |f| f.write(value) } end end |