Class: SpeakTextAction

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

Overview

Category: Device Actions

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(obj = nil) ⇒ SpeakTextAction

Returns a new instance of SpeakTextAction.



867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
# File 'lib/ruby-macrodroid/actions.rb', line 867

def initialize(obj=nil)
  
  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    e, macro = obj
    txt = e.text('item/description')
    {text: (txt || e.text)}
  end     

  options = {
    text_to_say: h[:text] || '',
    queue: false,
    read_numbers_individually: false,
    specify_audio_stream: false,
    speed: 0.99,
    pitch: 0.99,
    wait_to_finish: false,
    audio_stream: 0
  }

  super(options.merge h)

end

Instance Method Details

#invokeObject



892
893
894
# File 'lib/ruby-macrodroid/actions.rb', line 892

def invoke()
  super(text: @h[:text_to_say])
end

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



896
897
898
899
# File 'lib/ruby-macrodroid/actions.rb', line 896

def to_s(colour: false, indent: 0)
  @s = "Speak Text (%s)" % @h[:text_to_say]
  super()
end