Class: Alchemist::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/alchemist-server/commands/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(avatar_name, history) ⇒ Base

Returns a new instance of Base.



14
15
16
17
# File 'lib/alchemist-server/commands/base.rb', line 14

def initialize(avatar_name, history)
  @avatar_name = avatar_name
  @history = history
end

Instance Attribute Details

#avatar_nameObject (readonly)

Returns the value of attribute avatar_name.



12
13
14
# File 'lib/alchemist-server/commands/base.rb', line 12

def avatar_name
  @avatar_name
end

#historyObject (readonly)

Returns the value of attribute history.



12
13
14
# File 'lib/alchemist-server/commands/base.rb', line 12

def history
  @history
end

Class Method Details

.pattern(arg = nil) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/alchemist-server/commands/base.rb', line 4

def self.pattern(arg = nil)
  if arg
    @pattern = arg
  end

  @pattern
end

.run(avatar_name, history, *args) ⇒ Object



25
26
27
# File 'lib/alchemist-server/commands/base.rb', line 25

def self.run(avatar_name, history, *args)
  new(avatar_name, history).run *args
end

Instance Method Details

#outcome(response = nil, new_world = nil, command = nil) ⇒ Object



19
20
21
22
23
# File 'lib/alchemist-server/commands/base.rb', line 19

def outcome(response = nil, new_world = nil, command = nil)
  Outcome.new response: response,
              new_world: new_world,
              nearby_avatar_command: command
end