So one thing to note about working in the law enforcement field is that we're late to everything and technology is one of the big ones. I use computer programs that look like they come out of the 1980's. One of my favorite coworkers is a 67 year old man. He gets so flustered around computers that he'll leave a job with cushy days off and daytime hours (rare in law enforcement) if it involves computers. I imagine that the client I'm making my 404 finder for is him. I want to make things as streamlined and easy as possible. As far as our project, what do we have so far? Well we have a script that reads a file, assigns the string data in the file to a variable in our program, and then splits each URL into its own data point on the assumption that our use will input items with a space between each item.
Now we have to run through this array and find out the response code and then sort each URL into its respective group. For this we need to create some empty arrays which will be our groups.
Sweet! Now all we have to do is run our comparison and then use the .push method to push the items into their own arrays. Now, since the first language I learned was JavaScript, my first instinct was use a for loop. However, a .each is more appropriate iteration in Ruby. Not only is this more efficient, but it is also a lot easier than formatting a JavaScript for loop.
So this iterator will sort through your .txt file and tell what kind of link each link is! Now, you could consider yourself done, but that is entirely dependent on your user stories. I've got a few more ideas to make my code a little more friendly to people like my coworker.
No comments:
Post a Comment