Class: DisableMacroAction
- Inherits:
-
MacroDroidAction
- Object
- MacroObject
- Action
- MacroDroidAction
- DisableMacroAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ DisableMacroAction
constructor
A new instance of DisableMacroAction.
- #to_s(colour: false, indent: 0) ⇒ Object (also: #to_summary)
Methods inherited from Action
Methods included from ObjectX
#action_to_object, #object_create, #varify
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ DisableMacroAction
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 |
# File 'lib/ruby-macrodroid/actions.rb', line 1731 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 # state: 0 = enable, 1 = disable, 2 = toggle = {macro_name: "Change brightness", state: 1, GUID: nil} super(.merge h) end |
Instance Method Details
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
1762 1763 1764 1765 1766 1767 1768 1769 |
# File 'lib/ruby-macrodroid/actions.rb', line 1762 def to_s(colour: false, indent: 0) state = %w(Enable Disable Toggle)[@h[:state]] @s = state + ' macro'# + @h.inspect @s += "\n" + @h[:macro_name] super() end |