Web Dev Training with #WeGotCoders: Week 1
Intro to Ruby
This week’s been an introduction to Ruby. Strings, Control Structures, Data Structures, Methods, Classes & Objects and Code Blocks.
Transport for London Project
As part of the Data Structures track, we’ve been working on a command line app that plans a user's journey on the London Underground - Transport For London. This involves modelling a subsection of the tube network, prompting a user for their start and end stations, and printing out their route.
We chose to model the tube sub-network using a hash of arrays, and began the process with a procedural approach, prompting the user for input along the way.
I’ve been working on refactoring the code with an object-oriented approach, using a Journey class and initializing each journey object with a start and finish station.
Here’s the code so far: TFL Project
I’ve encapsulated each procedure within a method, so that the code prints out the stations between the user’s start and finish stations. If they need to change lines to complete their journey, Oxford Circus is the intersection point.
There’s 6 general journey outcomes:
Travelling eastbound on one line
Travelling westbound on one line
Travelling eastbound on more that one line
Travelling westbound on more that one line
Travelling eastbound, changing at oxford circus, and continuing westbound on another line
Travelling westbound, changing at oxford circus, and continuing eastbound on another line
Next Steps
Adding control flow so that the relevant method is called when a journey is entered.
Refactoring! There’s still lots of repetition and I’m using the return value of methods to access out of scope variables. This is making the code quite unwieldy and needs work....once I get my head around scope!










