Class: Birdy::Config
- Inherits:
-
Object
- Object
- Birdy::Config
- Defined in:
- lib/birdy/config.rb
Constant Summary collapse
- CONFIG_PATH =
"#{ENV['HOME']}/.config/birdy/"
- CONFIG_FILE =
CONFIG_PATH + "birdy.yml"
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #read ⇒ Object
- #write(login, password) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 9 |
# File 'lib/birdy/config.rb', line 7 def initialize FileUtils.mkdir_p CONFIG_PATH end |
Instance Method Details
#delete ⇒ Object
25 26 27 28 29 |
# File 'lib/birdy/config.rb', line 25 def delete File.delete(CONFIG_FILE) rescue nil end |
#read ⇒ Object
19 20 21 22 23 |
# File 'lib/birdy/config.rb', line 19 def read YAML.load_file(CONFIG_FILE) rescue {} end |
#write(login, password) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/birdy/config.rb', line 11 def write(login, password) config = {:login => login, :password => password} File.open(CONFIG_FILE, 'w') do |out| YAML.dump(config, out) end end |