Sha256: 41b5430ea23ef09acc52ff33a1b09865d5d5a49800e57e911ec9bb98d8df8b3a

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8

require 'yaml'
require 'vasputils'


# Class to deal with private settings for VaspUtils.

class VaspUtils::Setting
  class NoEntryError < Exception; end

  #
  def initialize(file = ENV["HOME"] + "/.vasputils")
    @data = YAML.load_file(file)
  end

  # Return value corresponding to a key.
  # Raise VaspUtils::Setting::NoEntryError if the key is not exist.
  def [](key)
    unless @data.include? key 
      raise NoEntryError, key
    end
    @data[key]
  end

  #def get(key)
  #  unless @data.include? key 
  #    raise NoEntryError, key
  #  end
  #  @data[key]
  #end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vasputils-0.0.11 lib/vasputils/setting.rb