Class: WifiConstraint

Inherits:
Constraint show all
Defined in:
lib/ruby-macrodroid/constraints.rb

Overview

Category: Connectivity

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Constraint

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ WifiConstraint

Returns a new instance of WifiConstraint.



290
291
292
293
294
295
296
297
298
299
# File 'lib/ruby-macrodroid/constraints.rb', line 290

def initialize(h={})

  options = {
    ssid_list: [],
    wifi_state: 0
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary



301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/ruby-macrodroid/constraints.rb', line 301

def to_s(colour: false, indent: 0)
  
  state = ['Enabled','Disabled','Connected', 'Not Connected'][@h[:wifi_state]]
  @s =  'Wifi ' + state + ': '
  
  if @h[:ssid_list].length > 1 then
    @s += "[%s]" % @h[:ssid_list].join(', ')
  elsif @h[:ssid_list].length > 0
    @s += @h[:ssid_list].first
  end
    
end