Ruby Basics


Which Language you prefer?

Programming like java etc
1 (100%)
Scripting like ruby
0 (0%)

Total Members Voted: 1

Voting closed: 03-18-2012, 06:00:55

Author Topic: Ruby Basics  (Read 3323 times)

Offline VinilTopic starter

  • Trade Count: (0)
  • Sr. Member
  • ****
  • Thank You 182
  • Posts: 301
  • Karma: 14
  • Gender: Male
  • I can and I Will
    • Boaters Directory
Ruby Basics
« on: 03-05-2012, 22:19:37 »
Hello all

From the past few days i have been trying to learn any scripting language.I caught Ruby.Its is one  of the best scripting language ,well known ,and language of future.Yes ,future language means it will be very much usefull in upcoming years in for web development etc.
1 Its is scripting language
2 Its is completely OOPs language.everything in ruby is an object except = (assignment operator)
3 NO compiler needed as the code we write is interpreted and then comes output
4 Syntactically easy
5 Case Sensitive
6 Often use ; at the end
7 Easy to learn the basics

I can give examples also
Example 1
puts " Hello World"

will generate output- Hello World

See there is no need to import any file,any API or library

Example 2
print "enter your name:"
puts "Hello #{name}"

will result
enter your name:

Hello ABCD

How pretty easy at all
you can use gets () like  gets  simply .
if you write like this
puts 'hello #{name}'

will generate output
hello #{name}

prints everything inside ' ' single quotes

8 Variables names always begin with small letter while class name begins with capital letters
like myname = "hello"
ruby interpreter automatically determine it to be string type variable
9 There is no datatype for VARIABLE but only for objects. So ,int num=3 is wrong .

will continue again till then read and post your view and knowledge in ruby basics

Offline VinilTopic starter

  • Trade Count: (0)
  • Sr. Member
  • ****
  • Thank You 182
  • Posts: 301
  • Karma: 14
  • Gender: Male
  • I can and I Will
    • Boaters Directory
Re: Ruby Basics
« Reply #1 on: 03-07-2012, 03:06:10 »
Few more things to know after that move to class in ruby
1 comments begin with #
2 instance variables - @instance_variable_declaration
3 methods declaration is like this
def method
#code here
4 if(expression) then
#code here
5 use notepad++ to run the ruby programs
its extension is .rb(mostly used)
to execute a ruby file in notepad++
step 1 save as hello.rb(for example)
press F5
type :
cmd /K current_location
where current location can be such that C:\vinci\hello.rb so the command will be
cmd /K C:\vinci\hello.rb
will gives the result

Class in ruby

1 class MyClass
#code here
2 Inheritance(NO multiple Inheritance)
Myclass < ParentClass
3 Object instatiation in ruby
4 getters and setters in ruby
def set
#code here
def get
#code here
RATHER use initailize method in class like this
def initialize(x,y)
Ruby calls this method automatically when an objects is created like the below,23) #object instantiation in ruby along with initializing variables

So easy to instantiate at all .
Deal all if you are willing to go for ruby ,i strongly recommend you do practice it
to be continue ..

Offline James Andy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 2
  • Posts: 91
  • Karma: 0
  • Gender: Male
Re: Ruby Basics
« Reply #2 on: 11-28-2012, 04:07:55 »
Nice post. I’ve been using Ruby, but need to start using Rails. This will help for me.

Offline Patrecia

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 104
  • Karma: 1
  • Gender: Female
    • local search marketing
Re: Ruby Basics
« Reply #3 on: 07-28-2013, 11:13:14 »
Thank you so much for this great details about Ruby language from many days I was thinking of learning it but thought it to be a tough one but really you post has given me some confidence great one  indeed ..keep updating more about Ruby here so that it can be helpful fo us.


Related Topics

  Subject / Started by Replies Last post
0 Replies
Last post 12-22-2015, 00:37:51
by aidenwilson342
7 Replies
Last post 10-12-2016, 23:55:30
by SEO.Ninja
0 Replies
Last post 11-05-2016, 02:40:04
by Brainpulse
0 Replies
Last post 12-09-2017, 04:08:42
by rubyrails
14 Replies
Last post 04-22-2020, 16:49:16
by digitalludhiana