Skip to content

Instantly share code, notes, and snippets.

msmith7904

Block or report user

Report or block msmith7904

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:934b40f6dc2225e6c228bcc05206a07d
<!-- same as above -->
<router-link :to="{ path: 'foo' }">Foo</router-link>
<!-- named route -->
<router-link :to="{ name: 'foo', params: { foo: 'bar' }}">Foo</router-link>
@msmith7904
msmith7904 / gist:5b91bb7ea5a3d3fa6989
Created Oct 26, 2014
Problematic Word Class Construction
View gist:5b91bb7ea5a3d3fa6989
class Word
def initialize(word)
@letters = word.split('').map do |letter|
{
:letter => letter,
:hidden => true
}
end
end
View Day 2 - Step 2
trains = {
"L Train" => "8th Ave, 6th Ave, Union Square, 3rd Ave, 1st Ave, Bedford Ave",
"N Train" => "Times Square, Herald Square, 28th St, 23rd St - HMH Nexus, Union Square, 8th Ave",
"6 Train" => "Grand Central, 33rd St, 28th St, 23rd St, Union Square, Astor Place"
}
loop do
puts "To view all train lines, type lines."
puts "To view all stations for line, type stations."
View Day 2 - Step 1
What were some of the issues with your first iteration of HMH Rail?
- It took way longer than it should have, considering its length. I got completely lost somewhere between steps 3 and 4.
Is there a lot of repeated code?
- Yes, for each if/eslif/else I repeated the same three lines of code. I also repeated the “You selected the __ train” string three times, which could possibly be replaced with a method that contains something along the lines of ‘puts “You selected the #{ } train.”’ I also repeated the string stating the stations options twice.
How flexible is the code?
- The code was not flexible at all. There was no way to add extra train lines and corresponding stations.
Where do you see room for improvement?
- All over the place to be honest.
What are the nouns for this problem domain? What real-world objects are we trying to represent through our code?
- Train lines, train stations.
View Step 5
def main_menu
puts "List train lines (T)? List Stations (Sta)? Quit program (Q)? Please make a selection."
end
loop do
main_menu
answer = gets.chomp.to_s
if answer == "T"
View Step 4
loop do
puts "List train lines (T)? List Stations (Sta)? Quit program (Q)? Please make a selection."
answer = gets.chomp.to_s
if answer == "T"
puts "The (L) Train, The (N) Train, The (S)ix Train"
elsif answer == "Sta"
puts "The (L) Train, The (N) Train, The (S)ix Train Choose a train line by letter."
View Step 3
loop do
puts "The (L) Train, The (N) Train, The (S)ix Train"
puts "Do you wish to quit?"
continue = gets.chomp
if continue == "Yes"
puts "Thank You"
break
else
puts "Choose a train line by letter."
end
View Step 2
puts "The (L) Train, The (N) Train, The (S)ix Train"
puts "Choose a train line by letter."
selection = gets.chomp.to_s
if selection == "L"
puts "You selected the L train."
puts "8th Ave, 6th Ave, Union Square, 3rd Ave, 1st Ave, Bedford Ave"
elsif selection == "N"
puts "You selected the N train."
puts "Times Square, Herald Square, 28th St, 23rd St - HMH Nexus,
View Step 1
puts "The (L) Train, The (N) Train, The (S)ix Train"
puts "Choose a train line by letter."
selection = gets.chomp.to_s
if selection == "L"
puts "You selected the L train."
elsif selection == "N"
puts "You selected the N train."
elsif selection == "S"
puts "You selected the Six Train."
You can’t perform that action at this time.