Class: Trigger
- Inherits:
-
MacroObject
- Object
- MacroObject
- Trigger
- Defined in:
- lib/ruby-macrodroid.rb
Direct Known Subclasses
ApplicationInstalledRemovedTrigger, ApplicationLaunchedTrigger, BatteryLevelTrigger, BatteryTemperatureTrigger, BluetoothTrigger, CalendarTrigger, CallActiveTrigger, CallEndedTrigger, CallMissedTrigger, DayTrigger, DeviceEventsTrigger, ExternalPowerTrigger, FloatingButtonTrigger, GeofenceTrigger, HeadphonesTrigger, IncomingCallTrigger, IncomingSMSTrigger, MediaButtonPressedTrigger, OutgoingCallTrigger, PowerButtonToggleTrigger, RegularIntervalTrigger, SensorsTrigger, ShortcutTrigger, SignalOnOffTrigger, StopwatchTrigger, SunriseSunsetTrigger, SwipeTrigger, TimerTrigger, UsbDeviceConnectionTrigger, VolumeButtonTrigger, WeatherTrigger, WebHookTrigger, WifiConnectionTrigger, WifiSSIDTrigger
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}) ⇒ Trigger
constructor
A new instance of Trigger.
- #match?(detail = {}, model = nil) ⇒ Boolean
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ Trigger
Returns a new instance of Trigger.
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 |
# File 'lib/ruby-macrodroid.rb', line 1238 def initialize(h={}) super({fakeIcon: 0}.merge(h)) @list << 'fakeIcon' # fetch the constraints @constraints = @h[:constraint_list].map do |constraint| object(constraint.to_snake_case) end end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
1236 1237 1238 |
# File 'lib/ruby-macrodroid.rb', line 1236 def constraints @constraints end |
Instance Method Details
#match?(detail = {}, model = nil) ⇒ Boolean
1249 1250 1251 1252 1253 1254 |
# File 'lib/ruby-macrodroid.rb', line 1249 def match?(detail={}, model=nil) # only match where the key exists in the trigger object detail.select {|k,v| @h.include? k }.all? {|key,value| @h[key] == value} end |