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.



1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
# File 'lib/ruby-macrodroid/actions.rb', line 1143

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



1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
# File 'lib/ruby-macrodroid/actions.rb', line 1163

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