Class: MediaButtonV2Trigger

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

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) ⇒ MediaButtonV2Trigger

Returns a new instance of MediaButtonV2Trigger.



1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
# File 'lib/ruby-macrodroid/triggers.rb', line 1725

def initialize(obj=nil)
  
  @a = %w(Play Play/Pause Pause Stop Previous Next Headset Hook)        
  
  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    e, macro = obj
    s = e.text('item/description').to_s
    a = s.split(/, /)
    {options_enabled_array: @a.map {|x| a.include? x } }
  end 


  
  options = {
    options_enabled_array: [true, false, false, false, false, false, false]
  }

  super(options.merge h)

end

Instance Method Details

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



1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
# File 'lib/ruby-macrodroid/triggers.rb', line 1748

def to_s(colour: false)
  
  
  options = @a.zip(@h[:options_enabled_array]).select(&:last).map(&:first)
  
  @s = 'Media Button V2 ' #+ @h.inspect
  @s += "\n" + options.join(', ')
  super()
  
end