This repository has been archived by the owner on May 14, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
53 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# coding: us-ascii | ||
require_relative 'helper' | ||
|
||
# yes or no | ||
bool = agree? 'Do you like this API?: ' | ||
show bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# coding: us-ascii | ||
require_relative 'helper' | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# coding: us-ascii | ||
require_relative 'helper' | ||
|
||
# with default value | ||
answer = ask "What's your favorite?: ", default: 'ruby' | ||
show answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# coding: us-ascii | ||
require_relative 'helper' | ||
|
||
# handle return value | ||
age = ask 'How old are you?: ', input: /\A(\d+)\z/, | ||
parse: ->s{Integer s}, | ||
return: 10..100 | ||
show age |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# coding: us-ascii | ||
$VERBOSE = true | ||
|
||
require_relative '../lib/io/nosey' | ||
|
||
include IO::Nosey | ||
|
||
def show(obj) | ||
puts "This script understands your input: #{obj.inspect}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# coding: us-ascii | ||
require_relative 'helper' | ||
|
||
# get secret word | ||
password = ask "What's your secret word?: ", echo: false | ||
show password |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# coding: us-ascii | ||
require_relative 'helper' | ||
|
||
# with input validation | ||
name = ask 'What\'s your name?("firstname lastname"): ', input: /\A\w+ \w+\z/ | ||
show name |