Ruby Tutorial : Let's communicate with Ruby Interactive Shell (IRB)


Let's start with some programming concepts.

Ruby Tutorial for Beginners : IRB

What is a variable ?

A variable is a piece of data that point to a specific name. For instance x=a+b where a and b can take many different values.


Open up command prompt (Ctrl+Alt+T or Win+R "Cmd")

$ irb

irb(main):001:0> a=15
=> 15
irb(main):002:0> b=52
=> 52
irb(main):003:0> c=a+b
=> 67
irb(main):004:0> 

If you observe the above snippet, a and b store 15, 52 respectively. c stores the summation of a and b.
   

  Float Type

In Ruby, floats can be defined either with numbers containing a decimal place.

irb(main):001:0> x=3.03
=> 3.03
irb(main):002:0> y=6.3
=> 6.3
irb(main):003:0> z=x+y
=> 9.33
irb(main):004:0> z
=> 9.33
irb(main):005:0> 


Strings 

Strings have one or more characters surrounded by quotes. For instance x="Welcome to Ruby programming"

irb(main):001:0> x="Hello"
=> "Hello"
irb(main):002:0> y=",World"
=> ",World"
irb(main):003:0> x
=> "Hello"
irb(main):004:0> y
=> ",World"
irb(main):005:0> d=x+"Hello"
=> "HelloHello"
irb(main):006:0> e=x+y+"Nice"
=> "Hello,WorldNice"
irb(main):007:0> e
=> "Hello,WorldNice"
irb(main):008:0> 

x contains a string "Hello", y also contains a string ",World". We can concatenate two or more strings using '+' operator.
e=x+y+"Nice"

Boolean 

Booleans can hold only two values true or false.

irb(main):001:0> x=false
=> false
irb(main):002:0> x
=> false
irb(main):003:0> 

Next lesson we will learn some arithmetical and mathematical operations.

Quick Way to Install Ruby on Your Computer


       We have discussed fascinating features of Ruby and why is Ruby favourite of many developers. It's time to write your very first Ruby program. Let's get started with Ruby.

Quick Way to Install Ruby on Your Computer

Install Ruby on Ubuntu 14.04

Open up the Terminal by holding Ctrl+Alt+T.
Ubuntu uses the apt package manager. You can use it like this:

$ sudo apt-get install ruby-full

Install on Mac OS X


     OS X Yosemite and Mavericks have pre-installed Ruby 2.0.  If you are using an older version of Mac OS X use the homebrew  package manager.

$ brew install ruby

Install on Windows 7/8


If you are on Windows platform, use the installer which helps to install ruby on windows .

Check the Ruby version 

Open up the terminal or Commands prompt (Windows - Go to Ruby folder >bin)

$ruby -v


Check the Interactive Ruby Shell (IRB)

IRB is an interactive shell, IRB allows the execution of Ruby commands with quick response, We can say it as a real-time tool for executing Ruby commands.

$irb 
puts "Welcome to IRB"


Done! Next lesson we will write a ruby program.

Why is Ruby popular and trending among developers


Ruby is developed by Yukihiro “Matz” Matsumoto , He has blended the language with his favourite languages including Perl,Smalltalk, Eiffel, Ada and Lisp.

If you look into the code of Ruby you will be surprised with its syntax. The creator says “Ruby is simple in appearance, but is very complex inside, just like our human body."

In 2006, Ruby grabbed acceptance from many developers. An adorable fact about Ruby is its free. Not only free of cost but also free to copy,modify and distribute.

In Ruby, everything is  related to an object. Ruby supports strong object-oriented features that available in many other OOP languages.

When you work on Ruby you will feel free to code anything because the language is seen as a flexible. Ruby users can easily alter its parts and user able to redefine the code.

Why is Ruby popular and trending among developers


Striking features of Ruby


1. Well defined exception handling that can able to tackle every error.
2. Ruby features a sweep garbage collector.
3. You can write C extensions easier than other popular procedure-oriented  languages.
4. Ruby supports Operating System independent threading.
5.  Ruby works everywhere! It works on many platforms such as Linux,Unix,Mac OS X, Windows 7/8, DOS,BeOS, OS/2 etc.

Ruby's good looking nature


Ruby uses very limited punctuation moreover it gives more priority to natural English words. Ruby does not need variable declarations. It uses naming conventions to indicate the scope of the variables.

@ and $ are special symbols of Ruby language, @var means that it's an instance variable and $var indicates that it's a global variable. Besides 'var' could be a local variable.


In next lesson, we will install Ruby on your computer.

How to Make a Mobile App Launcher Icon 15 Minutes




Nowadays Mobile Apps play a major role in digital life so today's tutorial I am going to teach you how to make a pixel perfect mobile app launcher icon using famous vector drawing tool Inkscape.

What we'll be creating - Mobile App Launcher Icon


This tutorial will help you to create a launcher icon that can be used for any location based service mobile application.

Setting up the environment for drawing
Open Inkscape software, and create a new document 500×500 pixels to change the default size of document press Shift+Ctrl+D (File->Document Properties) Press 1 to fit into the screen.
Select the "Rectangle and Squares Tool (press F4)" and drag out a square at the canvas 500 pixels wide and 500 pixels in height. Now change the color of square to green (#008000).

If you want to remove the border from filled square image just select it and press Shift +[none button].
Once you have completed the square, next create a circle (height : 211.400) after then remove the color of the circle
(press none button ) you will get a new image like below.
The created circle border should be around 33 pixels width [To change stroke width press Shift+Ctrl+F and select Stroke Style tab] don't forget to change the border color of the circle to white [select circle press Shift + White color from color palette ].
Select the circle object and duplicate it [press Ctrl+D to duplicate, Remember the duplicated object will be hidden until drag from existing object]. Drag and drop the duplicated object to the center of the circle. Fill up the newly created circle with white color.

Draw a 'V' shaped object to circle footer edge [Choose Bezier curves (or press Shift+F6)] White color will add a glossy look to location icon.

Choose a white color from color palette after selecting the V-shaped object.

Export Bitmap in Inkscape

File -> Export Bitmap save it as ic_launcher.png .
Done! The icon can be used on a mobile platform like Android, or iOS.