Class: AppConfig
Instance Method Summary collapse
- #[](field) ⇒ Object
-
#initialize(path) ⇒ AppConfig
constructor
A new instance of AppConfig.
Constructor Details
#initialize(path) ⇒ AppConfig
Returns a new instance of AppConfig.
7 8 9 |
# File 'lib/commercebank/appconfig.rb', line 7 def initialize(path) @path = path end |
Instance Method Details
#[](field) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/commercebank/appconfig.rb', line 11 def [](field) field = field.to_s path = File.(@path) config = File.exists?(path) ? YAML.load(File.read path) : Hash.new unless config[field] print "Please enter the following:\n" print field, ": " config[field] = gets.to_s.chomp File.open(path, 'w') {|file| file.write(config.to_yaml)} File.chmod(0600, path) end config[field] end |