Class: SetVariableAction
- Inherits:
-
Action
- Object
- MacroObject
- Action
- SetVariableAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Overview
MacroDroid Specific
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ SetVariableAction
constructor
A new instance of SetVariableAction.
- #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) ⇒ SetVariableAction
Returns a new instance of SetVariableAction.
1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 |
# File 'lib/ruby-macrodroid/actions.rb', line 1686 def initialize(obj=nil) h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro = obj node = e.element('item/*') #puts ("node.name: %s node.value: %s" % [node.name, node.value]).debug r = macro.set_var node.name, node.value.to_s puts ('r: ' + r.inspect).debug if $debug r if r[:type] == 2 then { variable: {name: r[:name], type: r[:type]}, new_string_value: r[:string_value] } end end = { :user_prompt=>true, :user_prompt_message=>"Please enter a word to see it reversed", :user_prompt_show_cancel=>true, :user_prompt_stop_after_cancel=>true, :user_prompt_title=>"Word reverse", :name => 'word', :false_label=>"False", :int_expression=>false, :int_random=>false, :int_random_max=>0, :int_random_min=>0, :int_value_decrement=>false, :int_value_increment=>false, :new_boolean_value=>false, :new_double_value=>0.0, :new_int_value=>0, :new_string_value=>"[battery]", :true_label=>"True", :user_prompt=>false, :user_prompt_show_cancel=>true, :user_prompt_stop_after_cancel=>true, :variable=>{ :exclude_from_log=>false, :is_local=>true, :boolean_value=>false, :decimal_value=>0.0, :int_value=>0, :name=>"foo", :string_value=>"52", :type=>2 } } super(.merge h) end |
Instance Method Details
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
1727 1728 1729 1730 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 1761 1762 1763 |
# File 'lib/ruby-macrodroid/actions.rb', line 1727 def to_s(colour: false, indent: 0) input = if @h[:user_prompt] then '[User Prompt]' elsif @h[:expression] @h[:expression] elsif @h[:int_value_increment] '(+1)' elsif @h[:int_value_decrement] '(-1)' elsif @h[:int_random] "Random %d -> %d" % [@h[:int_random_min], @h[:int_random_max]] else =begin sym = case @h[:variable][:type] when 0 # boolean :new_boolean_value when 1 # integer :new_int_value when 2 # string :new_string_value when 3 # decimal :new_double_value end @h[sym].to_s =end a = i(new_boolean_value new_int_value new_string_value new_double_value) @h[a[@h[:variable][:type]]].to_s end @s = 'Set Variable' + ("\n%s: " % @h[:variable][:name]) + input #+ @h.inspect super() end |