Skip to content

Commit

Permalink
Check if user input was an empty string. Update top level documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SelenaSmall committed Aug 28, 2017
1 parent a2e442a commit 7c3f750
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Toy robot simulator written in Ruby
*** ***


## Installation ## Installation
Environment: Built on Mac OSx using Ruby -v 2.4.1 Environment: Built on Mac OSX 10.11.6 using Ruby -v 2.4.1


Make sure you have the correct version of ruby installed Make sure you have the correct version of ruby installed
https://www.ruby-lang.org/en/documentation/installation/ https://www.ruby-lang.org/en/documentation/installation/


Clone this Repo Clone this Repo
> $ git clone https://github.com/selenasmall/toy_robot.git > $ git clone https://github.com/selenasmall/toy_robot.git
In root of the app run bundle install In root of the app run bundle install
Expand Down
6 changes: 4 additions & 2 deletions lib/action.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def report(position)


OPTIONS = %w[WEST NORTH EAST SOUTH].freeze OPTIONS = %w[WEST NORTH EAST SOUTH].freeze


# Prev Option method # Prev option method
# Find previous value in the options array # Find previous value in the options array
# @param direction [String] # @param direction [String]
# @param options [Array]
# @return previous direction # @return previous direction
def prev_option(direction) def prev_option(direction)
return unless OPTIONS.include?(direction) return unless OPTIONS.include?(direction)
Expand All @@ -68,9 +69,10 @@ def prev_option(direction)
OPTIONS.fetch(i) OPTIONS.fetch(i)
end end


# Next Option method # Next option method
# Find next value in the options array # Find next value in the options array
# @param direction [String] # @param direction [String]
# @param options [Array]
# @return next direction # @return next direction
def next_option(direction) def next_option(direction)
return unless OPTIONS.include?(direction) return unless OPTIONS.include?(direction)
Expand Down
2 changes: 2 additions & 0 deletions toy_robot.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
loop do loop do
input = gets.chomp input = gets.chomp


next if input.empty?

unless 'EXIT'.match?(input) unless 'EXIT'.match?(input)
command.interpret(input) command.interpret(input)
next next
Expand Down

0 comments on commit 7c3f750

Please sign in to comment.