Class: Snipe::Config
- Inherits:
-
Object
- Object
- Snipe::Config
- Defined in:
- lib/snipe/logic/config.rb
Constant Summary collapse
- FILE =
File.("~/.snipe")
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#from ⇒ Object
Returns the value of attribute from.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/snipe/logic/config.rb', line 8 def api_key @api_key end |
#domain ⇒ Object
Returns the value of attribute domain.
9 10 11 |
# File 'lib/snipe/logic/config.rb', line 9 def domain @domain end |
#from ⇒ Object
Returns the value of attribute from.
10 11 12 |
# File 'lib/snipe/logic/config.rb', line 10 def from @from end |
Class Method Details
.exists? ⇒ Boolean
12 13 14 |
# File 'lib/snipe/logic/config.rb', line 12 def self.exists? File.exists?(FILE) end |
Instance Method Details
#load ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/snipe/logic/config.rb', line 16 def load yaml = File.read(FILE) loaded = Psych.load(yaml) @api_key = loaded["api_key"] @domain = loaded["domain"] @from = loaded["from"] end |
#save ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/snipe/logic/config.rb', line 25 def save to_save = { "api_key" => @api_key, "domain" => @domain, "from" => @from } yaml = Psych.dump(to_save) File.write(FILE, yaml) end |