Short Notes on programs

What is Ruby?

Ruby is a programming language from Japan  which is revolutionizing the web. The beauty of Ruby is found in its balance between   simplicity and power.

Installing RVM :
So copy the below and paste it into terminal
$ sudo apt-­get install build­essential bison openssl libreadline6 libreadline6­ dev curl git­core zlib1g zlib1g­dev libssl­dev libyaml­dev libsqlite3­0 libsqlite3­dev sqlite3 libxml2­dev libxslt­dev autoconf libc6­dev ncurses­dev automake

Now install RVM using the following command
$ curl ­L https://get.rvm.io | bash ­s stable ­­ruby

Once done give these commands into terminal. These will tell Ubuntu GNU / Linux where to find the ruby interpreter.
$ echo ‘[[ ­s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm” # Load
$ ~/.bashrc
$ source ~/.bashrc

Once done, possibly restart computer and in terminal type the following
$ ruby ­v
It will spit an output somethin like this
ruby 1.9.3p194 (2012­04­20 revision 35410) [x86_64­linux]

Then all is OK!

Getting Started
Just enter the above command to getting started with ruby
$ irb
Type a line of Ruby code, hit Enter and watch it run!
For example, try typing some math. Like: 2 + 6 ,  3-6,  4*2, 4/2 and soon

Say Your Name
Sure, computers are handy and fast for math.
Let’s move on. Want to see your name reversed?
Type your first name in quotes like this: “Jimmy”

Say Your Name Reversed

Perfect, you’ve formed a string from the letters of your name. A string is a set of characters the computer can process.
Imagine the letters are on a string of laundry line and the quotes are clothespins holding the ends. The quotes mark the beginning and end.
To reverse your name, type: “Jimmy”.reverse (Don’t forget the dot!)

counting the letter

You have used the reverse method on your name!
By enclosing your name in quotes, you made a string. Then you called the reverse method, which works on strings to flip all the letters backwards.

on repeat
Now, I’m sure by now you’re wondering what any of this is good for. Well, I’m sure you’ve been to a website that screamed, Hey, your password is too short! See, some programs use this simple code.
Watch this. Let’s multiply your name by 5. “Jimmy” * 5

Methods.

You’ve used English-language methods like reverse and symbolic methods like * (the multiplication method.) Methods are actions!

This is the essence of your learning. Taking simple things, toying with them and turning them into new things. Feeling comfortable yet? I promise you are.
Okay, let’s do something uncomfortable. Try reversing a number: 40.reverse
Now, let’s see how many letters are in your name: “Jimmy”.length

3 comments on “Short Notes on programs

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