Class: Gamefic::Action::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/action.rb

Overview

Hooks are blocks of code that get executed before or after an actor performs an action. A before action hook is capable of cancelling the action’s performance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbs, callback) ⇒ Hook

Returns a new instance of Hook.



22
23
24
25
# File 'lib/gamefic/action.rb', line 22

def initialize verbs, callback
  @verbs = verbs
  @callback = callback
end

Instance Attribute Details

#callbackObject (readonly)

Parameters:



20
21
22
# File 'lib/gamefic/action.rb', line 20

def callback
  @callback
end

#verbsObject (readonly)

Parameters:



17
18
19
# File 'lib/gamefic/action.rb', line 17

def verbs
  @verbs
end

Instance Method Details

#match?(input) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/gamefic/action.rb', line 27

def match?(input)
  verbs.empty? || verbs.include?(input)
end