Class: MacroDroidVariableConstraint

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

Overview

Category: MacroDroid Specific

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Constraint

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ MacroDroidVariableConstraint

Returns a new instance of MacroDroidVariableConstraint.



795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
# File 'lib/ruby-macrodroid/constraints.rb', line 795

def initialize(h={})

  options = {
    
    :enable_regex=>false, 
    :boolean_value=>false, 
    :double_value=>0.0, 
    :int_compare_variable=>false, 
    :int_greater_than=>false, 
    :int_less_than=>false, 
    :int_not_equal=>false, 
    :int_value=>1, 
    :string_comparison_type=>0,
    :string_equal=>true, 
    :variable=>{
                :exclude_from_log=>false, 
                :is_local=>true, 
                :boolean_value=>false, 
                :decimal_value=>0.0, 
                :int_value=>2, 
                :name=>"torch", 
                :string_value=>"", 
                :type=>1
               }      

  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary



826
827
828
829
830
831
832
833
834
# File 'lib/ruby-macrodroid/constraints.rb', line 826

def to_s(colour: false, indent: 0)
  
    a = [:int_greater_than, :int_less_than, :int_not_equal, 
              :string_equal].zip(['>','<','!=', '='])
    operator = a.find {|label,_| @h[label]}.last
  
  @s = "%s %s %s" % [@h[:variable][:name], operator, @h[:int_value]]
  super()
end