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.



1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
# File 'lib/ruby-macrodroid/triggers.rb', line 1708

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



1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
# File 'lib/ruby-macrodroid/triggers.rb', line 1731

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