Skip to content

Instantly share code, notes, and snippets.

@johntdyer
Created October 26, 2012 17:05
Show Gist options
  • Select an option

  • Save johntdyer/3959962 to your computer and use it in GitHub Desktop.

Select an option

Save johntdyer/3959962 to your computer and use it in GitHub Desktop.
ask "", :choices => "[ANY]"
event = ask "When did Alexander Graham Bell patent the telephone? Was it A - January 30, 1877, B - March 10, 1876, or C - May 2, 1880?", {
:choices => "A(A, a), B(B, b), C(C, c)",
:attempts => 2,
:timeout => 60,
:onChoice => lambda { |event|
say "You chose " + event.value
if (event.value == "A")
say "That's right!"
else
say "I'm sorry, that's incorrect. Please try again!"
end
},
:onBadChoice => lambda { |event|
say "That wasn't one of the choices, please try again." },
:onTimeout => lambda { |event|
say "Sorry, didn't get that, please try again." }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment