Class: Rubywpa::WiFi

Inherits:
Object
  • Object
show all
Defined in:
lib/rubywpa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ WiFi

Create a new rubywpa instance and set the SSID.

wifi = Rubywpa::WiFi.new({
  :ssid => "MY_SSID",
  :mac  => "My_mac_address" # required for some networks
})
wifi.password

Yields:

  • (_self)

Yield Parameters:

  • _self (Rubywpa::WiFi)

    the object that the method was called on



17
18
19
20
21
22
23
# File 'lib/rubywpa.rb', line 17

def initialize(options = {}, &block)
  @ssid         = options[:ssid]
  @mac          = options[:mac]
  @country_code = options[:country_code]

  yield self if block_given?
end

Instance Attribute Details

#ssidObject

Returns the value of attribute ssid.



7
8
9
# File 'lib/rubywpa.rb', line 7

def ssid
  @ssid
end

Instance Method Details

#alice?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/rubywpa.rb', line 38

def alice?
  !!(ssid =~ /^Alice/i)
end

#fastweb?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rubywpa.rb', line 34

def fastweb?
  !!(ssid =~ /^FASTWEB/i)
end

#passwordObject



25
26
27
28
29
30
31
32
# File 'lib/rubywpa.rb', line 25

def password
  case
  when fastweb?      then Fastweb.compute(ssid)
  when alice?        then Alice.compute(ssid)
  else
    'Network not supported!'
  end
end