lib/larynx/prompt.rb in larynx-0.1.4 vs lib/larynx/prompt.rb in larynx-0.1.5

- old
+ new

@@ -11,20 +11,23 @@ # Pass a block to the method as a callback which receives input as an argument. # class Prompt attr_reader :call + COMMAND_OPTIONS = [:play, :speak, :phrase] + def initialize(call, options, &block) @call, @options, @block = call, options, block @options.reverse_merge!(:bargein => true, :timeout => 10, :interdigit_timeout => 3, :termchar => '#') raise NoPromptCommandValue, "No output command value supplied. Use one of playback, speak or phrase keys." if command_name.blank? end def command @command ||= AppCommand.new(command_name, message, :bargein => @options[:bargein]). - before { call.clear_input }. + before { call.clear_input unless @options[:bargein] }. after { + call.clear_input unless @options[:bargein] if prompt_finished? finalise else call.add_observer self add_digit_timer @@ -60,10 +63,10 @@ def timeout @options[:timeout] end def command_name - ([:play, :speak, :phrase] & @options.keys).first.to_s + (COMMAND_OPTIONS & @options.keys).first.to_s end def message @options[command_name.to_sym] end