Class: Trigger

Inherits:
MacroObject show all
Defined in:
lib/ruby-macrodroid.rb

Instance Attribute Summary collapse

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from MacroObject

#to_h, #to_s

Constructor Details

#initialize(h = {}) ⇒ Trigger

Returns a new instance of Trigger.



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
# File 'lib/ruby-macrodroid.rb', line 1189

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

#constraintsObject (readonly)

Returns the value of attribute constraints.



1187
1188
1189
# File 'lib/ruby-macrodroid.rb', line 1187

def constraints
  @constraints
end

Instance Method Details

#match?(detail = {}, model = nil) ⇒ Boolean

Returns:

  • (Boolean)


1200
1201
1202
1203
1204
1205
# File 'lib/ruby-macrodroid.rb', line 1200

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