Class: VaspUtils::Setting
- Inherits:
-
Object
- Object
- VaspUtils::Setting
- Defined in:
- lib/vasputils/setting.rb
Overview
Class to deal with private settings for VaspUtils.
Defined Under Namespace
Classes: NoEntryError
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Return value corresponding to a key.
-
#initialize(file = ENV["HOME"] + "/.vasputils") ⇒ Setting
constructor
A new instance of Setting.
Constructor Details
#initialize(file = ENV["HOME"] + "/.vasputils") ⇒ Setting
Returns a new instance of Setting.
15 16 17 18 |
# File 'lib/vasputils/setting.rb', line 15 def initialize(file = ENV["HOME"] + "/.vasputils") @filename = file @data = YAML.load_file(file) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
10 11 12 |
# File 'lib/vasputils/setting.rb', line 10 def filename @filename end |
Instance Method Details
#[](key) ⇒ Object
Return value corresponding to a key. Raise VaspUtils::Setting::NoEntryError if the key is not exist.
22 23 24 25 26 27 |
# File 'lib/vasputils/setting.rb', line 22 def [](key) unless @data.include? key raise NoEntryError, key end @data[key] end |