Sha256: 28778408c50af9752f41d684d068b82588c83977bcf28f7da72b7e8ced3c129d

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 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.12 lib/vasputils/setting.rb