Class: WifiConnectionTrigger

Inherits:
Trigger show all
Defined in:
lib/ruby-macrodroid/triggers.rb

Overview

Category: Connectivity

Instance Attribute Summary

Attributes inherited from Trigger

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Trigger

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(obj = nil) ⇒ WifiConnectionTrigger

Returns a new instance of WifiConnectionTrigger.



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/ruby-macrodroid/triggers.rb', line 473

def initialize(obj=nil)

  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    e, macro = obj
    {ssid_list: [e.text('item/description').to_s], wifi_state: 2}
  end 
  
  options = {
    ssid_list: [],
    wifi_state: 0
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false) ⇒ Object



491
492
493
494
495
496
# File 'lib/ruby-macrodroid/triggers.rb', line 491

def to_s(colour: false)
  access_point = @h[:ssid_list].first
  @s = 'Connected to network'
  @s += "\n" + access_point
  super()
end

#to_summaryObject



498
499
500
501
# File 'lib/ruby-macrodroid/triggers.rb', line 498

def to_summary()
  access_point = @h[:ssid_list].first
  'Connected to network' + access_point    
end