diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-10-08 00:10:29 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-10-09 23:33:48 -0300 |
commit | 8f8eb73bb873e4b91e04fd82d99935884dbb6f8f (patch) | |
tree | 81b717461ba1c68c77108fc566abe8312ded52ba | |
parent | 36d5ead9d29ec107a55bae8c5b254fe4c3ba54a4 (diff) | |
download | highline-8f8eb73bb873e4b91e04fd82d99935884dbb6f8f.tar.gz |
Merge all example snippets on README.md
-rw-r--r-- | README.md | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -38,40 +38,34 @@ Examples Basic usage: -```ruby ask("Company? ") { |q| q.default = "none" } -``` -Validation: -```ruby +# Validation + ask("Age? ", Integer) { |q| q.in = 0..105 } ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ } -``` -Type conversion for answers: -```ruby +# Type conversion for answers: + ask("Birthday? ", Date) ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) }) -``` -Reading passwords: -```ruby +# Reading passwords: + ask("Enter your password: ") { |q| q.echo = false } ask("Enter your password: ") { |q| q.echo = "x" } -``` -ERb based output (with HighLine's ANSI color tools): -```ruby +# ERb based output (with HighLine's ANSI color tools): + say("This should be <%= color('bold', BOLD) %>!") -``` -Menus: -```ruby +# Menus: + choose do |menu| menu.prompt = "Please choose your favorite programming language? " menu.choice(:ruby) { say("Good choice!") } |