Ruby on Rails development company in Delhi | Ruby | Rails

Ruby


Ruby is gaining popularity is the web development world. Ruby is used along with rails, the platform which made it popular. Ruby on Rails follows MVC style of web development. Popular social network Twitter is made using Ruby. There are other language options available for a developer also like PHP, ASP and JSP. Ruby is an object oriented language. It is open source and free to use in any project. It was created by a Japanese Yukihiro "Matz" Matsumoto in 1990.

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has the syntax which is easy to read and write. Yukihiro Matsumoto developed Ruby in 1995. This language minimizes the programmer’s works and minimizes the confusion of programming. It is a very active well organized community. The most striking features of Ruby are-

  • 1. Here variables declaration is not needed.
  • 2. Variables are not statically typed.
  • 3. Here syntax is simple and consistent.
  • 4. Here everything is an object.
  • 5. It has classes, methods and inheritance property.
  • 6. There is no need of semi colons.

Ruby programming language can be used in web application, iOS, android and other desktop applications.

Interactive Ruby:

Interactive Ruby (irb) is an interactive programming environment for Ruby that allows to quickly test various coding ideas. This programming environment is included with Ruby distribution. Irb is very good for learning Ruby through quick tests vs. editing files, saving and invoking. Irb is the foundation for the rails console. The symbolic link in /QOpenSys/usr/bin exists for the irb binary. Nil in screen shot is the reality that every Ruby method returns a value.

The data types of Ruby:

One does not have to declare variables with a particular data type. He or she gets data type when first used. Ruby interpreter looks at the type of value you are assigning to the variable and dynamically works out the variable type.

Constants:

Ruby’s constant starts with a capital letter. One can change a constant’s value but Ruby will issue a warning. Ruby variables are case sensitive so two of the below variables that are spelled the same are actually different. This_is_constant=”value” This_IS_constant=”value”

Strings:

Ruby strings use single or double quotes. Unicode is fully supported in Ruby. Ruby strings are interpolable with double quotes” hello # {world}. True, false and nill are keywords in Ruby. All are singletone classes. True and false are Boolean values in Ruby. Nil is the absence of value.

Symbols:

Ruby symbols start with colon symbol are immutable. In Ruby symbols are used for string values that do not change often to lessen CPU consumptions. In Ruby same named symbols are stored once immediately no matter how many times they are defined.

Number:

In Ruby numbers are immutable. Using decimal point the digit must appear before and after it. Underscore can be used to make the number user friendly on eyes.

Hash:

In ruby hashes store a list of indexed key value pairs=> is a hash rocket which separates keys from values.

Arrays:

In arrays keys are consecutive numbers. Arrays start at an index of zero. The left shift operation adds an element to the array.

Classes:

In Ruby classes are used when one needs to instantiate to a variable or for inheritance. In Ruby everything is an object. In Ruby methods are public by default.

Variables:

In ruby variables are case sensitive. Variables can contain letter, number and underscore but cannot begin with a number.

Ruby modules:

Modules are collection of classes, methods and constants. Modules are used for namespacing similar to Java’s package. Ruby modules support ‘mixins’.

Blocks:

Blocks consist of chunks of codes. Any method can accept a block. Blocks can be called immediately or stored for later use. Blocks are closures. If there is multiple lines use ‘do’ and ‘end’. If a single line is used then use {and}. In Ruby parameters are surrounded by the’ |’ character.

To invoke Ruby program:

Syntax:

Ruby/ifs /folder/path/program_name.rb To view an active Ruby runtime version: Ruby_v The symbolic link in/QOpenSys/usr/bin exists for the default ruby binary.

Comments in Ruby:

Comments start with # and continues to the end of the line=begin and =end allow for longer comments or commenting out a large portion of code. The syntax of Ruby is very much similar to Perl and Python. Here the class and method definitions are signalled by keywords. In contrast to Perl variables are not obligatory prefixed with a sigil. The syntax is sensitive to the capitalization of identifiers. Class and module names are constants and refer to objects derived from class and module. Here the sigil $ and @ do not indicate the variable data type as in Perl. Floating points must have digits on both sides of the decimal point. For example .8. Boolean and non-Boolean data types are permitted in Boolean contexts.