Class: Muby::Trigger

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

Defined Under Namespace

Classes: Shot

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, regexp, &block) ⇒ Trigger

Returns a new instance of Trigger.



20
21
22
23
24
25
# File 'lib/muby/trigger.rb', line 20

def initialize(type, regexp, &block)
  @regexp = regexp
  @block = block
  @type = type
  conf.send("#{@type}_triggers".to_sym)[@regexp] = self
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



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

def block
  @block
end

#regexpObject

Returns the value of attribute regexp.



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

def regexp
  @regexp
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#arityObject



26
27
28
# File 'lib/muby/trigger.rb', line 26

def arity
  3
end

#call(inwin, outwin, match) ⇒ Object



29
30
31
# File 'lib/muby/trigger.rb', line 29

def call(inwin, outwin, match)
  block.call(Shot.new(self, inwin, outwin, match))
end

#remove!Object



32
33
34
# File 'lib/muby/trigger.rb', line 32

def remove!
  conf.send("#{@type}_triggers".to_sym).delete(@regexp)
end