Class: TriggersNlp

Inherits:
Object
  • Object
show all
Includes:
AppRoutes
Defined in:
lib/ruby-macrodroid.rb

Instance Method Summary collapse

Constructor Details

#initialize ⇒ TriggersNlp

Returns a new instance of TriggersNlp.



20
21
22
23
24
25
26
# File 'lib/ruby-macrodroid.rb', line 20

def initialize()

  super()
  params = {}
  triggers(params)

end

Instance Method Details

#triggers(params) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ruby-macrodroid.rb', line 28

def triggers(params) 

  get /^(?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)/i do |time, days|
    [TimerTrigger, {time: time, days: days}]
  end

  # time.is? 'at 18:30pm on Mon or Tue'
  get /^time.is\? ['"](?:at )?(\d+:\d+(?:[ap]m)?) (?:on )?(.*)['"]/i do |time, days|      
    [TimerTrigger, {time: time, days: days.gsub(' or ',', ')}]
  end
  
  get /^shake[ _]device\??$/i do 
    [ShakeDeviceTrigger, {}]
  end
  
  get /^Flip Device (.*)$/i do |motion|
     facedown = motion =~ /Face Up (?:->|to) Face Down/i
    [FlipDeviceTrigger, {face_down: facedown }]
  end
  
  get /^flip_device_down\?$/i do
    [FlipDeviceTrigger, {face_down: true }]
  end

  get /^flip_device_up\?$/i do
    [FlipDeviceTrigger, {face_down: false }]
  end        
  
  get /^Failed Login Attempt$/i do
    [FailedLoginTrigger, {}]
  end
  
  get /^failed_login?$/i do
    [FailedLoginTrigger, {}]
  end         
      
  
end