27
Sep
09

Shift Subtitle, part 2

I find myself with some more free time today so I’ll forge ahead with this challenge!

The first thing I’m going to do here is add functionality to the options and arguments and make sure they are being read in correctly. Here is my resulting code:

http://charpcfn.pastebin.com/f454f0012

Now that those are all set I can start working on file I/O. I have no idea how Ruby handles this, but it’s probably pretty easy. Time for more google!

As I expected File I/O is pretty easy. infile is going to be read in line by line and then as the times are updated each line will be written to the outfile. I’m thinking about making a class SubtitleTime and have that handle the conversion from HH:MM:SS,mmm to an object, but I’m gonna sit on that idea for a while before implementing it.

I’m spending a lot of my time looking up specific syntax here. I made sure the ternary operator was normal as well as looking up lambdas which, apparently, you have to do function.call in order for it to work…That one was a stumper. I also really like how Ruby does regular expressions. My first introduction to REs were in Perl so this is a great throwback seeing the =~ operator again.

Anyway, I’m finished programming for now, here is the code I ended up with:

http://charpcfn.pastebin.com/f1e1b9214

Overall I spent more time looking up syntax than I did library function calls but am definitely learning a lot about the Ruby language.

Advertisements

0 Responses to “Shift Subtitle, part 2”



  1. Leave a Comment

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s


Challenges

How often I post

September 2009
M T W T F S S
    Oct »
 123456
78910111213
14151617181920
21222324252627
282930  

This is everything


%d bloggers like this: