class WebHookTrigger

Category: Connectivity

Public Class Methods

new(obj={}) click to toggle source
Calls superclass method Trigger::new
# File lib/ruby-macrodroid/triggers.rb, line 424
def initialize(obj={})
  
  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    
    e, macro = obj
    txt = e.text('item/description')
    
    h2 = if txt then
      {url: (txt || e.text)}
    else                
      a = e.xpath('item/*')
      a.map {|node| [node.name.to_sym, node.text.to_s]}.to_h        
    end      
    
    h2.merge(macro: macro)
  end        
  
  if h[:url] then
    h[:identifier] = h[:url]\
        [/https:\/\/trigger.macrodroid.com\/(?:\w+\-){4}\w+\/([^$]+)/,1]
  elsif h[:identifier].nil? or h[:identifier].empty? then
    h[:identifier] = h[:macro].title.downcase.gsub(/ +/,'-')
  end

  options = {
    identifier: ''
  }
  
  @deviceid = h[:macro].deviceid
      
  super(options.merge filter(options,h))
  @list << 'identifier'

end

Public Instance Methods

to_s(colour: false) click to toggle source
Calls superclass method Trigger#to_s
# File lib/ruby-macrodroid/triggers.rb, line 461
def to_s(colour: false)
  
  url = "https://trigger.macrodroid.com/%s/%s" % \
      [@deviceid, @h[:identifier]]
  @s = 'WebHook (Url)' + "\n" + url
  super()

end
Also aliased as: to_summary
to_summary(colour: false)
Alias for: to_s