Project

questions

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ask human
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
>= 0
>= 0
 Project Readme

Question

Ask questions to humans. Somebody has to select one of the specified answers typing the character(s) in the square brackets.

Installation

Add this line to your application's Gemfile:

gem 'questions'

And then execute:

$ bundle

Or install it via:

$ gem install questions

Usage

Preamble

require "questions"
include Questions

Long way

q = Question.new("File does exist, what should be done?")
q.answers = [:skip, :overwrite, :abort]
answer = q.ask
# SHELL:
# $ File does exist, what should be done? [s]kip, [o]verwrite, [a]bort
# s<enter>
answer #=> :skip

Short way

answer = Question.ask "File does exist, what should be done?", [:skip, :overwrite, :abort]
# SHELL:
# $ File does exist, what should be done? [s]kip, [o]verwrite, [a]bort
# s<enter>
answer #=> :skip

Hashish way

answer = Question.ask "File does exist, what should be done?", skip: true, overwrite: false, abort: true
# SHELL:
# $ File does exist, what should be done? [s]kip, [a]bort
# s<enter>
answer #=> :skip

Way with reaction

case Question.ask "Please select:", [:next, :exit]
when :next then next
when :exit then exit
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature-[short_description] or git checkout -b fix-[github_issue_number]-[short_description])
  3. Commit your changes (git commit -am 'Add some feature with tests')
  4. Push to the branch (git push origin [branch-name])
  5. Create new Pull Request