Class: WebHookTrigger
- Inherits:
-
Trigger
- Object
- MacroObject
- Trigger
- WebHookTrigger
- Defined in:
- lib/ruby-macrodroid/triggers.rb
Overview
Category: Connectivity
Instance Attribute Summary
Attributes inherited from Trigger
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = {}) ⇒ WebHookTrigger
constructor
A new instance of WebHookTrigger.
- #to_s(colour: false) ⇒ Object (also: #to_summary)
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(obj = {}) ⇒ WebHookTrigger
Returns a new instance of WebHookTrigger.
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# 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 = { identifier: '' } @deviceid = h[:macro].deviceid super(.merge filter(,h)) @list << 'identifier' end |
Instance Method Details
#to_s(colour: false) ⇒ Object Also known as: to_summary
461 462 463 464 465 466 467 468 |
# 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 |