Module: Ankit::Challenge::SlashRecognizing

Included in:
FailedState, MessageState, PassedStateBase, QuestionState
Defined in:
lib/ankit/challenge.rb

Instance Method Summary collapse

Instance Method Details

#pump_slash(command) ⇒ Object



315
316
317
318
319
320
321
322
323
324
# File 'lib/ankit/challenge.rb', line 315

def pump_slash(command)
  case command
  when "e", "edit"
    EditState.new(progress)
  when "z", "zero"
    QuestionState.new(progress)
  else
    MessageState.new(progress, "Unknown command: #{command} (Available: /edit, /zero)")
  end
end

#pump_slash_or(answered, &block) ⇒ Object



307
308
309
310
311
312
313
# File 'lib/ankit/challenge.rb', line 307

def pump_slash_or(answered, &block)
  if /^\/(\w+)/.match(answered)
    pump_slash($1) 
  else
    block.call()
  end
end