Class: VaspUtils::Setting

Inherits:
Object
  • Object
show all
Defined in:
lib/vasputils/setting.rb

Overview

Class to deal with private settings for VaspUtils.

Defined Under Namespace

Classes: NoEntryError

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#filenameObject (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