Class: AppConfig
Instance Method Summary collapse
- #[](field) ⇒ Object
- #[]=(field, value) ⇒ Object
- #get(field) ⇒ Object
-
#initialize(path) ⇒ AppConfig
constructor
A new instance of AppConfig.
Constructor Details
#initialize(path) ⇒ AppConfig
Returns a new instance of AppConfig.
4 5 6 |
# File 'lib/commercebank/appconfig.rb', line 4 def initialize(path) @path = path end |
Instance Method Details
#[](field) ⇒ Object
17 18 19 20 |
# File 'lib/commercebank/appconfig.rb', line 17 def [](field) field = field.to_s read[field] end |
#[]=(field, value) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/commercebank/appconfig.rb', line 8 def []=(field, value) field = field.to_s config = read config[field] = value config.delete(field) unless value save(config) value end |
#get(field) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/commercebank/appconfig.rb', line 22 def get(field) value = self[field] unless value print "Please enter the following:\n" print field, ": " value = self[field] = gets.to_s.chomp end value end |