A tiny assistant for CUI operations.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Split tutorial files May 13, 2013
lib/io Bump version to with tweaks Jun 17, 2015
spec Update dependencies with more strictly specs Jun 17, 2015
.gitignore Add ignores for git May 12, 2013
.yardopts Improve environments May 12, 2013
MIT-LICENSE Rename license file May 12, 2013
README.md Improve README Jun 17, 2015
Rakefile Improve environments May 12, 2013
io-nosey.gemspec Improve gemspec Jun 17, 2015



Build Status Gem Version Dependency Status


A tiny assistant for CUI operations.


  • #ask
  • #agree?
  • #choose
  • PureRuby :)

#ask's option parameter

input -> parse -> return

  1. input # validation for input string
  2. parse # procedure for input string
  3. return # validation for return value


  • default # when null input
  • echo # set "echo is (true or false)"
  • error # change error message when invalid input
  • multi_line # prefer multi_line mode for inputs(exit via ctrl+d)



Try below senario on REPL(ex. irb, pry) or excute "example/**_tutorial.rb"

require 'io/nosey'
include IO::Nosey

# input validation
ask 'What\'s your name?("firstname lastname"): ', input: /\A\w+ \w+\z/

# mix the validations and procedures
ask 'How old are you?: ', input:  /\A(\d+)\z/,
                          parse:  ->s{Integer s},
                          return: 10..100

# default value
ask "What's your favorite?: ", default: 'ruby'

# yes or no
agree? 'Do you like this API?: '

# for password
ask "What's your password?: ", echo: false

# choose one from collections
choose 'Which Five do you like?: ',  5      => '5 is a Integer',
                                   'five' => '"five" is a String',
                                   :FIVE  => ':FIVE is a Symbol'

# multi line mode
ask 'Write your poem and exit ctrl+d :) ', multi_line: true



gem install io-nosey



The MIT X11 License
Copyright (c) 2011 Kenichi Kamiya
See MIT-LICENSE for further details.