Class: LoopAction

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

Overview

Conditions/Loops

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Action

#invoke

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ LoopAction

Returns a new instance of LoopAction.



526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/ruby-macrodroid/actions.rb', line 526

def initialize(h={})
  
  options = {

  }
  
  h2 = options.merge(h)

  super(h2)
  
  @label = 'DO / WHILE '

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/ruby-macrodroid/actions.rb', line 540

def to_s(colour: false, indent: 0)
  
  h = @h.clone    
  h.delete :macro
  @s = 'DO / WHILE '
  operator = @h[:is_or_condition] ? 'OR' : 'AND'
  constraints = @constraints.map \
      {|x| '  ' * indent + x.to_summary(colour: colour)}.join(" %s " % operator)    
  
  out = []
  out << "; %s" % @h[:comment] if @h[:comment]
  s = @s.lines.map {|x| ('  ' * indent) + x}.join
  out << s + constraints
  out.join("\n")
  
end