Module: Gamefic::Scriptable::Syntaxes

Included in:
Gamefic::Scriptable, Responses
Defined in:
lib/gamefic/scriptable/syntaxes.rb

Instance Method Summary collapse

Instance Method Details

#interpret(command, translation) ⇒ Syntax

Create an alternate Syntax for a response. The command and its translation can be parameterized.

Examples:

Create a synonym for an ‘inventory` response.

interpret "catalogue", "inventory"
# The command "catalogue" will be translated to "inventory"

Create a parameterized synonym for a ‘look` response.

interpret "scrutinize :entity", "look :entity"
# The command "scrutinize chair" will be translated to "look chair"

Parameters:

  • command (String)

    The format of the original command

  • translation (String)

    The format of the translated command

Returns:

  • (Syntax)

    the Syntax object



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

def interpret command, translation
  syntaxes.push(Syntax.new(command, translation)).last
end

#syntaxesObject



24
25
26
# File 'lib/gamefic/scriptable/syntaxes.rb', line 24

def syntaxes
  @syntaxes ||= []
end