Class: MediaButtonPressedTrigger

Inherits:
Trigger show all
Defined in:
lib/ruby-macrodroid/triggers.rb

Overview

Category: User Input

Instance Attribute Summary

Attributes inherited from Trigger

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Trigger

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(obj = nil) ⇒ MediaButtonPressedTrigger

Returns a new instance of MediaButtonPressedTrigger.



1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
# File 'lib/ruby-macrodroid/triggers.rb', line 1694

def initialize(obj=nil)

  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    e, macro = obj
    {option: e.text('item/description').to_s}
  end 
  
  options = {
    option: 'Single Press',
    cancel_press: false
  }

  super(options.merge h)

end

Instance Method Details

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



1712
1713
1714
1715
1716
1717
1718
# File 'lib/ruby-macrodroid/triggers.rb', line 1712

def to_s(colour: false)
  
  @s = 'Media Button Pressed ' #+ @h.inspect
  @s += "\n" + @h[:option]
  super()
  
end