Class: Relish::OptionsFile
- Inherits:
-
Object
- Object
- Relish::OptionsFile
- Defined in:
- lib/relish/options_file.rb
Overview
Represents a .relish file
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
-
#initialize(path) ⇒ OptionsFile
constructor
A new instance of OptionsFile.
- #merge(other) ⇒ Object
-
#options ⇒ Object
Stored options as a hash.
-
#store(options) ⇒ Object
Store the given options into the file.
Constructor Details
#initialize(path) ⇒ OptionsFile
Returns a new instance of OptionsFile.
9 10 11 |
# File 'lib/relish/options_file.rb', line 9 def initialize(path) @path = path end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 |
# File 'lib/relish/options_file.rb', line 27 def == (other) == other end |
#[](key) ⇒ Object
23 24 25 |
# File 'lib/relish/options_file.rb', line 23 def [](key) [key] end |
#merge(other) ⇒ Object
31 32 33 |
# File 'lib/relish/options_file.rb', line 31 def merge(other) .merge(other.) end |
#options ⇒ Object
Stored options as a hash
36 37 38 |
# File 'lib/relish/options_file.rb', line 36 def @options ||= end |
#store(options) ⇒ Object
Store the given options into the file. Existing options with the same keys will be overwritten.
15 16 17 18 19 20 21 |
# File 'lib/relish/options_file.rb', line 15 def store() @options = self..merge() FileUtils.touch(@path) File.open(@path, 'w') do |file| YAML.dump(@options, file) end end |