diff options
author | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-07-01 22:57:07 -0300 |
---|---|---|
committer | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-07-01 23:42:10 -0300 |
commit | 92872eaf3e200df50fac5fe5e8ce1c8b2d1373aa (patch) | |
tree | 5f548ad08c4e96752536153c756841d97fd1e67c /examples | |
parent | 492b61377ceabe3c4d91ba8ed44ca245dbc5f43c (diff) | |
download | highline-92872eaf3e200df50fac5fe5e8ce1c8b2d1373aa.tar.gz |
Apply manual fixes for rubocop warnings
Diffstat (limited to 'examples')
-rw-r--r-- | examples/basic_usage.rb | 14 | ||||
-rw-r--r-- | examples/menus.rb | 6 | ||||
-rw-r--r-- | examples/repeat_entry.rb | 3 |
3 files changed, 12 insertions, 11 deletions
diff --git a/examples/basic_usage.rb b/examples/basic_usage.rb index 3f28b02..c31fc46 100644 --- a/examples/basic_usage.rb +++ b/examples/basic_usage.rb @@ -16,11 +16,10 @@ contacts = [] class NameClass def self.parse(string) - if string =~ /^\s*(\w+),\s*(\w+)\s*$/ - new(Regexp.last_match(2), Regexp.last_match(1)) - else - raise ArgumentError, "Invalid name format." - end + raise ArgumentError, "Invalid name format." unless + string =~ /^\s*(\w+),\s*(\w+)\s*$/ + + new(Regexp.last_match(2), Regexp.last_match(1)) end def initialize(first, last) @@ -31,7 +30,7 @@ class NameClass attr_reader :first, :last end -begin +loop do entry = {} # basic output @@ -70,7 +69,8 @@ begin contacts << entry # shortcut for yes and no questions -end while agree("Enter another contact? ", true) + break unless agree("Enter another contact? ", true) +end if agree("Save these contacts? ", true) file_name = ask("Enter a file name: ") do |q| diff --git a/examples/menus.rb b/examples/menus.rb index 5941f17..92cfc51 100644 --- a/examples/menus.rb +++ b/examples/menus.rb @@ -24,7 +24,7 @@ say("\nThis is the new mode (default)...") choose do |menu| menu.prompt = "Please choose your favorite programming language? " - menu.choice :ruby do say("Good choice!") end + menu.choice(:ruby) { say("Good choice!") } menu.choices(:python, :perl) { say("Not from around here, are you?") } menu.default = :ruby @@ -37,7 +37,7 @@ choose do |menu| menu.prompt = "Please choose your favorite programming language? " - menu.choice :ruby do say("Good choice!") end + menu.choice(:ruby) { say("Good choice!") } menu.choices(:python, :perl) { say("Not from around here, are you?") } end @@ -48,7 +48,7 @@ choose do |menu| menu.header = "Languages" menu.prompt = "Favorite? " - menu.choice :ruby do say("Good choice!") end + menu.choice(:ruby) { say("Good choice!") } menu.choices(:python, :perl) { say("Not from around here, are you?") } end diff --git a/examples/repeat_entry.rb b/examples/repeat_entry.rb index 9afd7ec..35cdbbd 100644 --- a/examples/repeat_entry.rb +++ b/examples/repeat_entry.rb @@ -6,7 +6,8 @@ require "highline/import" puts "Using: #{HighLine.default_instance.terminal.class}" puts -tounge_twister = ask("... try saying that three times fast") do |q| +# tounge_twister +ask("... try saying that three times fast") do |q| q.gather = 3 q.verify_match = true q.responses[:mismatch] = "Nope, those don't match. Try again." |