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.



1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
# File 'lib/ruby-macrodroid/actions.rb', line 1211

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



1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
# File 'lib/ruby-macrodroid/actions.rb', line 1231

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