Class: VibrateAction

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

Overview

Category: Device Settings

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 = {}) ⇒ VibrateAction

Returns a new instance of VibrateAction.



1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
# File 'lib/ruby-macrodroid/actions.rb', line 1353

def initialize(h={})
  
  pattern = [
    'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing', 
    'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
    'Mini Blip', 'Micro Blip'
  ]    
  
  if h[:pattern] then
    h[:vibrate_pattern] = pattern.map(&:downcase).index h[:pattern]
  end
  
  options = {
    vibrate_pattern: 1
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object



1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
# File 'lib/ruby-macrodroid/actions.rb', line 1373

def to_s(colour: false, indent: 0)
  
  pattern = [
    'Blip', 'Short Buzz', 'Long Buzz', 'Rapid', 'Slow', 'Increasing', 
    'Constant', 'Decreasing', 'Final Fantasy', 'Game Over', 'Star Wars',
    'Mini Blip', 'Micro Blip'
  ]
  
  'Vibrate ' + "(%s)" % pattern[@h[:vibrate_pattern].to_i]
end