Learning Ruby

I may of been accepted to an internship with a really good mobile dev startup. They use Ruby on Rails so for the past few day I’ve been trying it out. It’s more different than Java than I imagined. It’s simple and nice, but I still don’t know any of the syntax. Today I got Ruby running on eclipse and I tried out this tutorial. It runs, but I have no idea what it’s supposed to do. I think I’m supposed to assign file with some value and I never did.

I understand the code for the most part. I can’t wait until I understand it as well as I understand Java and XML.

http://neurogami.com/content/10_minutes_to_your_first_Ruby_app/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Launcher

def initialize app_map
 @app_map = app_map
 end

def run file_name
 application = select_app file_name
 system "#{application} #{file_name}"
 end

def select_app file_name
 ftype = file_type file_name
 @app_map[ ftype ]
 end

def file_type file_name
 File.extname( file_name ).gsub( /^\./,'').downcase
 end
end

def help
 print "
 You must pass in the path fo the file to launch.
 Usage: #{__FILE__} target_file
 "
end

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Advertisements

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