Class: WLIConfig::Options
- Inherits:
-
Object
- Object
- WLIConfig::Options
- Defined in:
- lib/wliconfig.rb
Overview
Commandline option container
Instance Attribute Summary collapse
-
#addr ⇒ Object
Returns the value of attribute addr.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#product ⇒ Object
Returns the value of attribute product.
-
#user ⇒ Object
Returns the value of attribute user.
-
#wlan_key ⇒ Object
Returns the value of attribute wlan_key.
-
#wlan_mode ⇒ Object
Returns the value of attribute wlan_mode.
-
#wlan_ssid ⇒ Object
Returns the value of attribute wlan_ssid.
Instance Method Summary collapse
Instance Attribute Details
#addr ⇒ Object
Returns the value of attribute addr.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def addr @addr end |
#pass ⇒ Object
Returns the value of attribute pass.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def pass @pass end |
#product ⇒ Object
Returns the value of attribute product.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def product @product end |
#user ⇒ Object
Returns the value of attribute user.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def user @user end |
#wlan_key ⇒ Object
Returns the value of attribute wlan_key.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def wlan_key @wlan_key end |
#wlan_mode ⇒ Object
Returns the value of attribute wlan_mode.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def wlan_mode @wlan_mode end |
#wlan_ssid ⇒ Object
Returns the value of attribute wlan_ssid.
83 84 85 |
# File 'lib/wliconfig.rb', line 83 def wlan_ssid @wlan_ssid end |
Instance Method Details
#update_from_file(fname) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/wliconfig.rb', line 85 def update_from_file(fname) return unless fname if FileTest.exist?(fname) $wlog.info("Configuration file #{fname} does exist.") open(fname){|f| yaml = YAML.load(f.read) @addr ||= yaml["addr"] @user ||= yaml["user"] @pass ||= yaml["pass"] @wlan_ssid ||= yaml["wlan-ssid"] @wlan_mode ||= yaml["wlan-mode"] @wlan_key ||= yaml["wlan-key"] } true else $wlog.warn("Configuration file #{fname} does not exist.") false end end |
#update_from_map(map) ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/wliconfig.rb', line 105 def update_from_map(map) @addr = map[:addr] || @addr @user = map[:user] || @user @pass = map[:pass] || @pass @wlan_ssid = map[:wlan_ssid] || @wlan_ssid @wlan_mode = map[:wlan_mode] || @wlan_mode @wlan_key = map[:wlan_key] || @wlan_key end |
#valid? ⇒ Boolean
114 115 116 |
# File 'lib/wliconfig.rb', line 114 def valid? [@addr, @user, @pass, @wlan_ssid, @wlan_mode, @wlan_key].count(nil) == 0 end |