Class: ForceMacroRunAction

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

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(obj = nil) ⇒ ForceMacroRunAction

Returns a new instance of ForceMacroRunAction.



1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
# File 'lib/ruby-macrodroid/actions.rb', line 1877

def initialize(obj=nil)
  
  h = if obj.is_a? Hash then
  
    obj
    
  elsif obj.is_a? Array
    
    e, macro, h2 = obj
    
    # find the macro guid for the given name
    name = e.text('item/description').to_s
    found = macro.parent.macros.find {|macro| macro.title =~ /#{name}/ }
    
    h3 = if found then     
      {macro_name: found.title, GUID: found.guid}
    else
      {macro_name: name}
    end
    
    h3.merge h2

  end      
  
  options = {
    guid: nil, ignore_constraints: true, 
    macro_name: "", use_off_status: false, 
    user_prompt_title: "Run Macro"      
  }
  super(options.merge h)
  
end

Instance Method Details

#invokeObject



1910
1911
1912
# File 'lib/ruby-macrodroid/actions.rb', line 1910

def invoke()
  super(macro_name: @h[:macro_name])
end

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



1914
1915
1916
1917
1918
1919
1920
# File 'lib/ruby-macrodroid/actions.rb', line 1914

def to_s(colour: false, indent: 0)
  
  @s = 'Macro Run'# + @h.inspect
  @s += "\n" + @h[:macro_name]
  super()
  
end