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.



1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
# File 'lib/ruby-macrodroid/actions.rb', line 1089

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



1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
# File 'lib/ruby-macrodroid/actions.rb', line 1109

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