Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ellijayne/2cf19e685302d184c170c8c8b4776bcb to your computer and use it in GitHub Desktop.
Save ellijayne/2cf19e685302d184c170c8c8b4776bcb to your computer and use it in GitHub Desktop.
MTA
require 'pry'
require 'rainbow'
def plan_trip (line, start_stop, end_stop)
n_line = ["times square", "n_34th", "n_28th", "n_23rd", "union square", "n_8th"]
puts Rainbow(n_line).green
l_line = ["l_8th", "l_6th", "union square", "l_3rd", "l_1st"]
puts Rainbow(l_line).red
six_line = ["grand central", "s_33rd", "s_28th", "s_23rd", "union square", "astor place"]
puts Rainbow(six_line).yellow
if line == "n-line"
$line_arry = n_line #putting $ at front makes it a global variable.
end
if line == "l-line"
$line_arry = l_line #here i am storing the l_line in the var $line_arry
end
if line == "6-line"
$line_arry = six_line
end
def index (start_stop, end_stop)
puts i_start = $line_arry.index(start_stop)
puts i_end = $line_arry.index(end_stop)
if i_start > i_end
result = $line_arry[i_start..i_end].reverse ############################
else
result = $line_arry[i_start..i_end]
end
end
indexresult = index("union square", "n_34th").join(', ') #calling func here and storing result in var.
#printing out input
puts Rainbow("Your journey starts on the #{line} at #{start_stop}. You will then travel though the following stops: #{indexresult}, before you get off the #{line} at #{end_stop}").cyan
# p result
end
result = plan_trip("n-line", "union square", "n_34th")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment