lib/cliprompt/optionset.rb in cliprompt-0.0.2 vs lib/cliprompt/optionset.rb in cliprompt-0.0.3

- old
+ new

@@ -54,11 +54,11 @@ def parse_float(arg) @default = arg.to_s end def parse_string(arg) - if arg.downcase.match /^y(es)?(\/)?n(o)?/ + if arg.match /^[yY1](es)?(\/)?[nN0](o)?/ @boolean = true if /y(es)?(\/)?N/.match arg @default = false else @default = true @@ -97,12 +97,11 @@ return ask_again(question, Cliprompt::MSG_MANDATORY_TEXT) if @default.nil? @default end def check_boolean(question, answer) - answer.downcase! - return ask_again(question, Cliprompt::MSG_YES_OR_NO) unless /^(y(es)?|n(o)?)$/.match(answer) - !/^y(es)?$/.match(answer).nil? + return ask_again(question, Cliprompt::MSG_YES_OR_NO) unless /^([yY1](es)?|[nN0](o)?)$/.match(answer) + !/^[yY1](es)?$/.match(answer).nil? end def check_choices(question, answer) return ask_again(question, Cliprompt::MSG_CHOSE_IN_LIST) unless @choices.include?(answer) answer