Permalink
Browse files

doc

  • Loading branch information...
1 parent c9bbba1 commit 5ac8ab32d54d937174fdb3f651520badabf5dcb7 @kachick committed Jul 19, 2012
Showing with 41 additions and 39 deletions.
  1. +1 −1 Manifest.txt
  2. +1 −1 README.rdoc
  3. +0 −37 example/example.rb
  4. +39 −0 example/tutorial.rb
View
@@ -8,4 +8,4 @@ lib/io/nosey/version.rb
lib/io/nosey/noseyparker.rb
test/test_helper.rb
test/test_io-nosey.rb
-example/example.rb
+example/tutorial.rb
View
@@ -37,7 +37,7 @@ A tiny assistant for CUI operations.
=== Tutorial
Try below senario.
-Or excute "example/example.rb".
+Or excute "example/tutorial.rb".
==== shell
View
@@ -1,37 +0,0 @@
-$VERBOSE = true
-
-# * setup
-require_relative '../lib/io/nosey'
-
-include IO::Nosey
-
-def show(obj)
- puts "This script understands your input: #{obj.inspect}"
-end
-
-# * with input validation
-name = ask "What's your name?", input: /\A\w+ \w+\z/
-show name
-
-# * with default value
-answer = ask "What's your favorite?", default: 'ruby'
-show answer
-
-# * handle return value
-last_name, family_name = ask "What's your name?", input: /\A\w+ \w+\z/, parse: ->s{s.split}
-show "LastName: #{last_name}"
-show "FamilyName: #{family_name}"
-age = ask 'How old are you?', input: /\A(\d+)\z/, parse: ->s{Integer s}, return: 10..100
-show age
-
-# * yes or no
-bool = agree? 'Do you like this API?'
-show bool
-
-# * get password
-password = ask "What's your password?", echo: false
-show password
-
-# * choose one
-choice = choose 'Which Five do you like?', 5 => 'Integer', 'five' => 'String', :FIVE => 'Symbol'
-show choice
View
@@ -0,0 +1,39 @@
+$VERBOSE = true
+
+# setup
+require_relative '../lib/io/nosey'
+
+include IO::Nosey
+
+def show(obj)
+ puts "This script understands your input: #{obj.inspect}"
+end
+
+# with input validation
+name = ask "What's your name?", input: /\A\w+ \w+\z/
+show name
+
+# with default value
+answer = ask "What's your favorite?", default: 'ruby'
+show answer
+
+# handle return value
+age = ask 'How old are you?', input: /\A(\d+)\z/,
+ parse: ->s{Integer s},
+ return: 10..100
+show age
+
+# yes or no
+bool = agree? 'Do you like this API?'
+show bool
+
+# get password
+password = ask "What's your password?", echo: false
+show password
+
+# choose one
+choice = \
+ choose 'Which Five do you like?', 5 => '5 is a Integer',
+ 'five' => '"five" is a String',
+ :FIVE => ':FIVE is a Symbol'
+show choice

0 comments on commit 5ac8ab3

Please sign in to comment.