Class: SetBluetoothAction

Inherits:
ConnectivityAction show all
Defined in:
lib/ruby-macrodroid/actions.rb

Overview

Category: Connectivity

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Action

#invoke

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ SetBluetoothAction

Returns a new instance of SetBluetoothAction.



841
842
843
844
845
846
847
848
849
850
851
852
# File 'lib/ruby-macrodroid/actions.rb', line 841

def initialize(h={})

  options = {
    
    device_address: '',
    device_name: '',
    state: 1
  }

  super(options.merge h)

end

Instance Method Details

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



854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'lib/ruby-macrodroid/actions.rb', line 854

def to_s(colour: false, indent: 0)
  
  @s = if @h[:state] <= 2 then
  
    state = %w(Enable Disable Toggle)[@h[:state]]
    state + ' Bluetooth'
    
  else
    
    state = @h[:state] == 3 ? 'Connect' : 'Disconnect'
    state + ' Audio Device' + "\n" + @h[:device_name]
    
  end

  super()
  
end