Shift Subtitle, part 4

Well now it’s just a matter of debugging my code. I suppose writing tests would be the ideal thing to do, but I think there is just a stupid typo in there somewhere that I’ll have to look for.

Ok. I had some ideas while I started working. It pretty much went like this:

  1. Reading in the times is working but assumes they are always in full format (ie 00:00:00,000) and does not handle 00,000 situations.
  2. the to_s method is terrible, I’ve only used sprintf once or twice in PHP so it’s no wonder I didn’t think of it right off. That cleaned it up quite a bit.

So after figuring out a way to read in the times and account for partial time entries, I did a bit of refactoring and testing and found out that it’s working now, horray!
I just thought of another, probably easier way this could have been accomplished. If I had taken the file times, converted them to milliseconds and then added/subtracted the converted input times then spit them back out as HH:MM:SS,mmm it might have been less verbose code, but I think this was a good exercise to learn a bit about Ruby classes. And anyways, my code works and that’s all that counts, right?


That’s my submitted code!

Can’t wait for the next challenge :]

edit: If I find myself with some extra time I will probably go back and write some unit tests and maybe try making it a Gem as practice since there is still a while before the next challenge starts.


2 Responses to “Shift Subtitle, part 4”

  1. 1 lee
    September 29, 2009 at 4:33 pm

    Not bad, I might have approached it differently, if I had the time – maybe the next challenge.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


How often I post

September 2009
    Oct »

This is everything


%d bloggers like this: