Class: Butler::Plugin::Trigger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin, language, trigger) ⇒ Trigger

Returns a new instance of Trigger.



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

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.



16
17
18
# File 'lib/butler/plugin/trigger.rb', line 16

def authorization
  @authorization
end

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#languageObject (readonly)

Returns the value of attribute language.



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

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pluginObject (readonly)

Returns the value of attribute plugin.



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

def plugin
  @plugin
end

#triggerObject (readonly)

Returns the value of attribute trigger.



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

def trigger
  @trigger
end

Instance Method Details

#<=>(other) ⇒ Object



45
46
47
# File 'lib/butler/plugin/trigger.rb', line 45

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

#abort_invocations?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/butler/plugin/trigger.rb', line 49

def abort_invocations?
	true
end

#call(message) ⇒ Object



37
38
39
# File 'lib/butler/plugin/trigger.rb', line 37

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/butler/plugin/trigger.rb', line 53

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

#invoked_by?(message) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/butler/plugin/trigger.rb', line 33

def invoked_by?(message)
	[]
end

#priorityObject



41
42
43
# File 'lib/butler/plugin/trigger.rb', line 41

def priority
	0
end