Class: Muby::Trigger
- Inherits:
-
Object
- Object
- Muby::Trigger
- Defined in:
- lib/muby/trigger.rb
Defined Under Namespace
Classes: Shot
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#regexp ⇒ Object
Returns the value of attribute regexp.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #arity ⇒ Object
- #call(inwin, outwin, match) ⇒ Object
-
#initialize(type, regexp, &block) ⇒ Trigger
constructor
A new instance of Trigger.
- #remove! ⇒ Object
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
#block ⇒ Object
Returns the value of attribute block.
19 20 21 |
# File 'lib/muby/trigger.rb', line 19 def block @block end |
#regexp ⇒ Object
Returns the value of attribute regexp.
19 20 21 |
# File 'lib/muby/trigger.rb', line 19 def regexp @regexp end |
#type ⇒ Object
Returns the value of attribute type.
19 20 21 |
# File 'lib/muby/trigger.rb', line 19 def type @type end |
Instance Method Details
#arity ⇒ Object
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 |