Class: Butler::Plugin::Trigger

Inherits:
Object
  • Object
show all
Defined in:
lib/butler/plugin/trigger.rb

Constant Summary collapse

Priority =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin, language, trigger) ⇒ Trigger

Returns a new instance of Trigger.



26
27
28
29
30
31
32
33
# File 'lib/butler/plugin/trigger.rb', line 26

def initialize(plugin, language, trigger)
  @plugin        = plugin
  @language      = language
  @trigger       = trigger.downcase
  @authorization = "plugin/#{@plugin.base}".freeze
  @name          = "trigger:#{@language}:#{@trigger}".freeze
  @hash          = @name.hash
end

Instance Attribute Details

#authorizationObject (readonly)

Returns the value of attribute authorization.



18
19
20
# File 'lib/butler/plugin/trigger.rb', line 18

def authorization
  @authorization
end

#hashObject (readonly)

Returns the value of attribute hash.



19
20
21
# File 'lib/butler/plugin/trigger.rb', line 19

def hash
  @hash
end

#languageObject (readonly)

Returns the value of attribute language.



20
21
22
# File 'lib/butler/plugin/trigger.rb', line 20

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/butler/plugin/trigger.rb', line 21

def name
  @name
end

#pluginObject (readonly)

Returns the value of attribute plugin.



22
23
24
# File 'lib/butler/plugin/trigger.rb', line 22

def plugin
  @plugin
end

#triggerObject (readonly)

Returns the value of attribute trigger.



23
24
25
# File 'lib/butler/plugin/trigger.rb', line 23

def trigger
  @trigger
end

Instance Method Details

#<=>(other) ⇒ Object



47
48
49
# File 'lib/butler/plugin/trigger.rb', line 47

def <=>(other)
  other.priority <=> Priority
end

#abort_invocations?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/butler/plugin/trigger.rb', line 51

def abort_invocations?
  true
end

#call(message) ⇒ Object



39
40
41
# File 'lib/butler/plugin/trigger.rb', line 39

def call(message)
  @plugin.new(message).on_trigger
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/butler/plugin/trigger.rb', line 55

def eql?(other)
  other.kind_of?(Trigger) && @name.eql?(other.name)
end

#invoked_by?(message) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/butler/plugin/trigger.rb', line 35

def invoked_by?(message)
  []
end

#priorityObject



43
44
45
# File 'lib/butler/plugin/trigger.rb', line 43

def priority
  Priority
end