Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A tiny assistant for CUI operations.
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
lib/io
spec Add multi_line option for #ask
.gitignore
.travis.yml
.yardopts
Gemfile
MIT-LICENSE
README.md
Rakefile
io-nosey.gemspec

README.md

io-nosey

Build Status Gem Version

Description

A tiny assistant for CUI operations.

Features

  • #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

Other

  • 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)

Usage

Tutorial

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

Requirements

Install

gem install io-nosey

Link

License

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

Something went wrong with that request. Please try again.