Class: Alchemist::Event
Instance Attribute Summary collapse
-
#command_string ⇒ Object
readonly
Returns the value of attribute command_string.
Instance Method Summary collapse
- #happen(history) ⇒ Object
-
#initialize(command_string, time) ⇒ Event
constructor
A new instance of Event.
- #to_s ⇒ Object
Constructor Details
#initialize(command_string, time) ⇒ Event
Returns a new instance of Event.
5 6 7 8 |
# File 'lib/alchemist-server/event.rb', line 5 def initialize(command_string, time) @command_string = command_string @time = time end |
Instance Attribute Details
#command_string ⇒ Object (readonly)
Returns the value of attribute command_string.
3 4 5 |
# File 'lib/alchemist-server/event.rb', line 3 def command_string @command_string end |
Instance Method Details
#happen(history) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/alchemist-server/event.rb', line 10 def happen(history) avatar_name, command, *args = @command_string.split /\s+/ if command_mod = COMMANDS.detect { |c| match_command? command, c } command_mod.run avatar_name, history, *args else Outcome.new response: "error Unknown Command: #{command}" end end |
#to_s ⇒ Object
20 21 22 23 24 25 |
# File 'lib/alchemist-server/event.rb', line 20 def to_s <<-str #{@command_string} #{@time} str end |