Class: TplinkAdmin::Configuration
- Inherits:
-
Object
- Object
- TplinkAdmin::Configuration
- Defined in:
- lib/tplink-admin/configuration.rb
Constant Summary collapse
- CONFIG_FILE =
"#{ENV['HOME']}/.tplinkadmin"
Instance Attribute Summary collapse
-
#hostname_length ⇒ Object
Returns the value of attribute hostname_length.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#hostname_length ⇒ Object
Returns the value of attribute hostname_length.
7 8 9 |
# File 'lib/tplink-admin/configuration.rb', line 7 def hostname_length @hostname_length end |
#hosts ⇒ Object
Returns the value of attribute hosts.
8 9 10 |
# File 'lib/tplink-admin/configuration.rb', line 8 def hosts @hosts end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/tplink-admin/configuration.rb', line 6 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/tplink-admin/configuration.rb', line 4 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/tplink-admin/configuration.rb', line 5 def username @username end |
Class Method Details
.instance ⇒ Object
20 21 22 |
# File 'lib/tplink-admin/configuration.rb', line 20 def self.instance @instance ||= File.exists?(CONFIG_FILE) ? load_yml() : new.tap(&:defaults) end |
.load_yml ⇒ Object
24 25 26 |
# File 'lib/tplink-admin/configuration.rb', line 24 def self.load_yml YAML.load_file(CONFIG_FILE) end |
.save ⇒ Object
28 29 30 |
# File 'lib/tplink-admin/configuration.rb', line 28 def self.save File.open(CONFIG_FILE, 'w+') { |f| f.write(instance.to_yaml) } end |
Instance Method Details
#defaults ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/tplink-admin/configuration.rb', line 12 def defaults self.hosts ||= {} self.hostname_length ||= 16 self.username ||= 'admin' self.password ||= 'admin' self.url ||= '192.168.0.1' end |