SlideShare a Scribd company logo
RUBY
Introduction to Ruby Programming Language
by Kostas Platis
“
”
I HOPE TO SEE RUBY HELP EVERY PROGRAMMER IN
THE WORLD TO BE PRODUCTIVE, AND TO ENJOY
PROGRAMMING, AND TO BE HAPPY. THAT IS THE
PRIMARY PURPOSE OF RUBY LANGUAGE.
Yukihiro Matsumoto Google Tech Talk(2008)
•Created in 1993 by Yukihiro Matsumoto
•Initially 2 names were proposed :“Coral” and “Ruby”
•His aim was to create a programming language easy-to-use
DYNAMIC
“Dynamic programming language is a term used
in computer science to describe a class of high-level
programming languages which, at runtime, execute
many common programming behaviors that static
programming languages perform during compilation.”
wikipedia.com
Ruby is a dynamic programming language
OBJECT-ORIENTED
 Ruby is pure object-oriented language and everything appears to
Ruby as an object
 Even a class itself is an object that is an instance of the Class class
 Ruby is based on the concept of “objects” , classes , attributes and
methods.
GENERAL PURPOSE
Ruby is a programming language designed to be used for
writing software in a wide variety of application domains like:
• Server-Side(Ruby-on-Rails)
• Web Servers
• Common GUI Applications
• Low-Level systems
FAMOUS APPLICATIONS WRITTEN IN
RUBY
 Simulations
NASA Langley Research Center uses Ruby to conduct simulations.
 3D Modeling
Google SketchUp is a 3D modeling application that uses Ruby for its macro scripting API.
 Robotics
At MORPHA project, Ruby was used to implemented the reactive control part for the
Siemens service robot.
 Web Applications Implemented in Rails
VERSIONS
• Ruby 1.0: December1996
• Ruby 1.2: December 1998
• Ruby 1.4: August 1999
• Ruby 1.6: September 2000
• Ruby 1.8: August 2003
• Ruby 1.9: December 2007
• Ruby 2.1: December 2013
• Ruby 2.2: December 2014
RUBY INSTALLATION
Ubuntu
1) Open Terminal
2) apt-add-repository ppa:brightbox/ruby-ng
3) apt-get update
4) apt-get install ruby 2.2
5) Done!
Windows
1) Open www.rubyinstaller.org
2) Download Ruby 2.2.3
3) Install RubyInstaller
RUBY GEMS
As most programming languages, Ruby offers a wide set of third-
party libraries.
Most of them are released in the form of a gem
RubyGems is a package manager for the Ruby programming
language that provides a standard format for distributing Ruby
programs and libraries
RUBY RVM
RVM(Ruby Version Manager) is a command-line tool which allows
you to easily install, manage, and work with multiple ruby
environments from interpreters to sets of gems.
RVM is a programmer’s helping hand for :
1. Production
RVM lets you deploy each project with its own completely self-
contained and dedicated environment, from the specific version of
ruby, all the way down to the precise set of required gems to run
your application. With RVM, NO OTHER GEMS than those required
are installed. Efficiency when working on complex applications
RUBY RVM
2. Testing
RVM enables you to easily test both upgrade and escape paths
very easily and consistently. With RVM, you can run a test suite, rake
tasks, benchmarks and gem commands against multiple ruby
versions at the same time.
3. Gem Management
RVM has an extremely flexible gem management system called
Named Gem Sets. RVM's 'gemsets' make managing gems across
multiple versions of Ruby a non-issue.
Note : RVM is for Ruby applications, *not just for Rails*! Any Ruby
based application will benefit from your use of RVM.
RVM INSTALLATION
Ubuntu
1. Open Terminal
3) curl –sSL https://get.rvm.io | bash
4) Done!
Windows
RVM is not developed for Windows. An alternative is pik
(https://github.com/vertiginous/pik)
IRB
Interactive Ruby Shell (IRB or irb) is a REPL for programming in Ruby. The
program is launched from a command line and allows the execution of
Ruby commands with immediate response, experimenting in real-time.
 irb is executed using the “irb” command.
 Use “exit” to exit irb
IRB
We can use irb in order to evaluate a variety of
expressions
You can also invoke a single program with irb
RUBY IDE
For Ruby Developing I personally use and recommend RubyMine (Developed by
JetBrains)
RubyMine is free for Students
RubyMine Installation
1. https://www.jetbrains.com/ruby
2. Download and install RubyMine
3. Create JetBrains Account
4. Apply for Student licence in www.jetbrains.com/student
5. Open RubyMine and login using your account
IN GENERAL
• Ruby files use the suffix .rb
• Comments start with #
• Multiple line comments use =begin , =end
• nil(null in other programming languages) means that the
object is an instance of the Nil Class
• Blocks end using the “end” statement
• Variables dynamically change their type
NAMING
Ruby has some strange naming conventions
1. Local varibles, method’s parameters and method’s
names are written in lowercase
2. Constants are written in capital letters
3. Global variables are prefixed with the dollar sign ($)
4. Field names are prefixed with the “at” sign "@"
5. Class names are prefixed with the “double at” sign "@@"
CLASSES & OBJECTS
Class ClassName
attr_accessor :var1,:var2
<methods>
End
Constructors are named “initialize(param1,param2…)”
attr_accessor is used as getter,setter
 Inheritance is a thing
 Multiple Inheritance is not
objectTitle = ClassName.new(param1,param2…)
METHODS
def method_name(param_1,param_2...)
<code>
<code>
<code>
end
• “return” is not necessary. The returned value is the latest
changed variable
• Method block ends with “end”
STRING
CHARACTERISTICS
• “n” is used as line breaker
• If we want to use a variable name inside a string we just
add #{variable_name}
• Alternatively, we can use the + operator in order to unite 2
or more strings
• Double quote vs Single quotes : Double quotes allow you
to do string interpolation
ARRAYS
• Arrays, like variables, dont need initialization
• temp = Array.new(10)
• puts temp.size or puts temp.length
• We can save variables of different type
• Values are saved as A = ['A','B','C'] or A[0] = 1 etc
SHORTCUT %w
%w is used in order to initialize arrays alternatively,
A = %w{ A B C }
HASHES
• To initialize Hashes we use curly braces instead of braces
• In order to initialize a map :
"key => value"
Note : keys are unique, values are not
• temp = Hash.new
Hash Display
 temp[:key]
 If key does not exist, nil is returned
CONDITIONAL
STRUCTURES
• main body does not require curly braces { }
• Condition does not require parentheses
• If main body contains only one command, the command
can go before the condition
• Conditional structures are :
 if-elsif-else,
 Case-when (like switch-case)
 unless-else
LOOPS
• main body does not require curly braces { }
• Condition does not require parentheses
• Known loops are :
1. while[condition]-end, begin-while[condition]
2. begin – end until [condition]
3. for i in 0…j
 next : is used in order to pass to the next value
 redo : restarts the iteration of the most internal loop,
without checking loop condition.
 If retry appears in rescue clause of begin expression,
restart from the beginning of the 1begin body.
CODE BLOCKS
Ruby includes a pretty cool feature : The Code Blocks
• We can call a method which has the same name but
different body by using the yield command
• Any code surrounded by curly braces is a block
• The calling can include arguments called
Block arguments
{|arg1,arg2| code_including_args}
CODE BLOCKS
Yeah…ok but whats the usage?
1. To keep things concise and understandable
2. To create more elegant code
3. To iterate lists (especially in Rails)
ITERATORS
 .each method for arrays & hashes (block)
 times & upto(-number-) for numbers
Iterators can be used as blocks
I/O
2 main ways to output
1. puts (like println in Java)
2. printf (Like in C/C++)
 gets is the main way to input data
EXCEPTIONS
Are handled using begin-rescue
Some known Exception subclasses are:
 NoMemoryError
 ScriptError
 StandardError
 SystemExit
 SystemStackError
WHY RUBY?
1. Ruby allows the programmer to do things fast (less code – but
takes time to learn). That’s why Ruby programmers are happy 
2. Open-Source (Hundreds of recourses – everything is free! –
gems usage)
3. Everything is free! Gems usage save time and money
4. Ruby On Rails (Rails conventions)
RESOURCES
 www.ruby-lang.org (Ruby Official Site)
 www.tutorialspoint.com/ruby (Examples provider)
 www.rubylearning.com (Useful Tutorials)
 www.rubyinstaller.org (Installer for Windows)
 www.jetbrains.com/ruby (RubyMine IDE)
THANK YOU!
Kostas Platis
Email : platico.dev@gmail.com
Slideshare : www.slideshare.net/platico_dev

More Related Content

What's hot

Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
Michael MacDonald
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
Aimee Maree Forsstrom
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
Introduction to Qt
Introduction to QtIntroduction to Qt
Introduction to Qt
Puja Pramudya
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
akhilsreyas
 
Generics
GenericsGenerics
Generics
Ravi_Kant_Sahu
 
Java: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh EditionJava: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh Edition
moxuji
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Python my sql database connection
Python my sql   database connectionPython my sql   database connection
Python my sql database connection
Learnbay Datascience
 
Python : Data Types
Python : Data TypesPython : Data Types
Python Presentation
Python PresentationPython Presentation
Python Presentation
Narendra Sisodiya
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Ranjith Siji
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
Abhishek Sur
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QML
Alan Uthoff
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
 

What's hot (20)

Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Introduction to Qt
Introduction to QtIntroduction to Qt
Introduction to Qt
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Generics
GenericsGenerics
Generics
 
Java: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh EditionJava: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh Edition
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Python my sql database connection
Python my sql   database connectionPython my sql   database connection
Python my sql database connection
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QML
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 

Similar to Ruby Presentation

Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
Muhammad Haseeb Shahid
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystem
Geison Goes
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
IT Weekend
 
Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02
sagaroceanic11
 
Why ruby
Why rubyWhy ruby
Why ruby
Bill Chea
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
Hiroshi SHIBATA
 
l-rubysocks-a4
l-rubysocks-a4l-rubysocks-a4
l-rubysocks-a4
tutorialsruby
 
l-rubysocks-a4
l-rubysocks-a4l-rubysocks-a4
l-rubysocks-a4
tutorialsruby
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
myuser
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
Mark Menard
 
Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby for C# Developers
Ruby for C# DevelopersRuby for C# Developers
Ruby for C# Developers
Cory Foy
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
Henry S
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
Thomas Asikis
 
2 Basics
2 Basics2 Basics
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
Blazing Cloud
 
Pengantar Ruby on Rails
Pengantar Ruby on RailsPengantar Ruby on Rails
Pengantar Ruby on Rails
Ashari Juang
 
Ruby Hell Yeah
Ruby Hell YeahRuby Hell Yeah
Ruby Hell Yeah
Anupom Syam
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
Hiroshi SHIBATA
 
Ruby
RubyRuby

Similar to Ruby Presentation (20)

Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystem
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02
 
Why ruby
Why rubyWhy ruby
Why ruby
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
l-rubysocks-a4
l-rubysocks-a4l-rubysocks-a4
l-rubysocks-a4
 
l-rubysocks-a4
l-rubysocks-a4l-rubysocks-a4
l-rubysocks-a4
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Ruby for C# Developers
Ruby for C# DevelopersRuby for C# Developers
Ruby for C# Developers
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
2 Basics
2 Basics2 Basics
2 Basics
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
 
Pengantar Ruby on Rails
Pengantar Ruby on RailsPengantar Ruby on Rails
Pengantar Ruby on Rails
 
Ruby Hell Yeah
Ruby Hell YeahRuby Hell Yeah
Ruby Hell Yeah
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
Ruby
RubyRuby
Ruby
 

Recently uploaded

What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 

Recently uploaded (20)

What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 

Ruby Presentation

  • 1. RUBY Introduction to Ruby Programming Language by Kostas Platis
  • 2. “ ” I HOPE TO SEE RUBY HELP EVERY PROGRAMMER IN THE WORLD TO BE PRODUCTIVE, AND TO ENJOY PROGRAMMING, AND TO BE HAPPY. THAT IS THE PRIMARY PURPOSE OF RUBY LANGUAGE. Yukihiro Matsumoto Google Tech Talk(2008) •Created in 1993 by Yukihiro Matsumoto •Initially 2 names were proposed :“Coral” and “Ruby” •His aim was to create a programming language easy-to-use
  • 3. DYNAMIC “Dynamic programming language is a term used in computer science to describe a class of high-level programming languages which, at runtime, execute many common programming behaviors that static programming languages perform during compilation.” wikipedia.com Ruby is a dynamic programming language
  • 4. OBJECT-ORIENTED  Ruby is pure object-oriented language and everything appears to Ruby as an object  Even a class itself is an object that is an instance of the Class class  Ruby is based on the concept of “objects” , classes , attributes and methods.
  • 5. GENERAL PURPOSE Ruby is a programming language designed to be used for writing software in a wide variety of application domains like: • Server-Side(Ruby-on-Rails) • Web Servers • Common GUI Applications • Low-Level systems
  • 6. FAMOUS APPLICATIONS WRITTEN IN RUBY  Simulations NASA Langley Research Center uses Ruby to conduct simulations.  3D Modeling Google SketchUp is a 3D modeling application that uses Ruby for its macro scripting API.  Robotics At MORPHA project, Ruby was used to implemented the reactive control part for the Siemens service robot.  Web Applications Implemented in Rails
  • 7. VERSIONS • Ruby 1.0: December1996 • Ruby 1.2: December 1998 • Ruby 1.4: August 1999 • Ruby 1.6: September 2000 • Ruby 1.8: August 2003 • Ruby 1.9: December 2007 • Ruby 2.1: December 2013 • Ruby 2.2: December 2014
  • 8. RUBY INSTALLATION Ubuntu 1) Open Terminal 2) apt-add-repository ppa:brightbox/ruby-ng 3) apt-get update 4) apt-get install ruby 2.2 5) Done! Windows 1) Open www.rubyinstaller.org 2) Download Ruby 2.2.3 3) Install RubyInstaller
  • 9. RUBY GEMS As most programming languages, Ruby offers a wide set of third- party libraries. Most of them are released in the form of a gem RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries
  • 10. RUBY RVM RVM(Ruby Version Manager) is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. RVM is a programmer’s helping hand for : 1. Production RVM lets you deploy each project with its own completely self- contained and dedicated environment, from the specific version of ruby, all the way down to the precise set of required gems to run your application. With RVM, NO OTHER GEMS than those required are installed. Efficiency when working on complex applications
  • 11. RUBY RVM 2. Testing RVM enables you to easily test both upgrade and escape paths very easily and consistently. With RVM, you can run a test suite, rake tasks, benchmarks and gem commands against multiple ruby versions at the same time. 3. Gem Management RVM has an extremely flexible gem management system called Named Gem Sets. RVM's 'gemsets' make managing gems across multiple versions of Ruby a non-issue. Note : RVM is for Ruby applications, *not just for Rails*! Any Ruby based application will benefit from your use of RVM.
  • 12. RVM INSTALLATION Ubuntu 1. Open Terminal 3) curl –sSL https://get.rvm.io | bash 4) Done! Windows RVM is not developed for Windows. An alternative is pik (https://github.com/vertiginous/pik)
  • 13. IRB Interactive Ruby Shell (IRB or irb) is a REPL for programming in Ruby. The program is launched from a command line and allows the execution of Ruby commands with immediate response, experimenting in real-time.  irb is executed using the “irb” command.  Use “exit” to exit irb
  • 14. IRB We can use irb in order to evaluate a variety of expressions You can also invoke a single program with irb
  • 15. RUBY IDE For Ruby Developing I personally use and recommend RubyMine (Developed by JetBrains) RubyMine is free for Students RubyMine Installation 1. https://www.jetbrains.com/ruby 2. Download and install RubyMine 3. Create JetBrains Account 4. Apply for Student licence in www.jetbrains.com/student 5. Open RubyMine and login using your account
  • 16. IN GENERAL • Ruby files use the suffix .rb • Comments start with # • Multiple line comments use =begin , =end • nil(null in other programming languages) means that the object is an instance of the Nil Class • Blocks end using the “end” statement • Variables dynamically change their type
  • 17. NAMING Ruby has some strange naming conventions 1. Local varibles, method’s parameters and method’s names are written in lowercase 2. Constants are written in capital letters 3. Global variables are prefixed with the dollar sign ($) 4. Field names are prefixed with the “at” sign "@" 5. Class names are prefixed with the “double at” sign "@@"
  • 18. CLASSES & OBJECTS Class ClassName attr_accessor :var1,:var2 <methods> End Constructors are named “initialize(param1,param2…)” attr_accessor is used as getter,setter  Inheritance is a thing  Multiple Inheritance is not objectTitle = ClassName.new(param1,param2…)
  • 19. METHODS def method_name(param_1,param_2...) <code> <code> <code> end • “return” is not necessary. The returned value is the latest changed variable • Method block ends with “end”
  • 20. STRING CHARACTERISTICS • “n” is used as line breaker • If we want to use a variable name inside a string we just add #{variable_name} • Alternatively, we can use the + operator in order to unite 2 or more strings • Double quote vs Single quotes : Double quotes allow you to do string interpolation
  • 21. ARRAYS • Arrays, like variables, dont need initialization • temp = Array.new(10) • puts temp.size or puts temp.length • We can save variables of different type • Values are saved as A = ['A','B','C'] or A[0] = 1 etc SHORTCUT %w %w is used in order to initialize arrays alternatively, A = %w{ A B C }
  • 22. HASHES • To initialize Hashes we use curly braces instead of braces • In order to initialize a map : "key => value" Note : keys are unique, values are not • temp = Hash.new Hash Display  temp[:key]  If key does not exist, nil is returned
  • 23. CONDITIONAL STRUCTURES • main body does not require curly braces { } • Condition does not require parentheses • If main body contains only one command, the command can go before the condition • Conditional structures are :  if-elsif-else,  Case-when (like switch-case)  unless-else
  • 24. LOOPS • main body does not require curly braces { } • Condition does not require parentheses • Known loops are : 1. while[condition]-end, begin-while[condition] 2. begin – end until [condition] 3. for i in 0…j  next : is used in order to pass to the next value  redo : restarts the iteration of the most internal loop, without checking loop condition.  If retry appears in rescue clause of begin expression, restart from the beginning of the 1begin body.
  • 25. CODE BLOCKS Ruby includes a pretty cool feature : The Code Blocks • We can call a method which has the same name but different body by using the yield command • Any code surrounded by curly braces is a block • The calling can include arguments called Block arguments {|arg1,arg2| code_including_args}
  • 26. CODE BLOCKS Yeah…ok but whats the usage? 1. To keep things concise and understandable 2. To create more elegant code 3. To iterate lists (especially in Rails)
  • 27. ITERATORS  .each method for arrays & hashes (block)  times & upto(-number-) for numbers Iterators can be used as blocks
  • 28. I/O 2 main ways to output 1. puts (like println in Java) 2. printf (Like in C/C++)  gets is the main way to input data
  • 29. EXCEPTIONS Are handled using begin-rescue Some known Exception subclasses are:  NoMemoryError  ScriptError  StandardError  SystemExit  SystemStackError
  • 30. WHY RUBY? 1. Ruby allows the programmer to do things fast (less code – but takes time to learn). That’s why Ruby programmers are happy  2. Open-Source (Hundreds of recourses – everything is free! – gems usage) 3. Everything is free! Gems usage save time and money 4. Ruby On Rails (Rails conventions)
  • 31. RESOURCES  www.ruby-lang.org (Ruby Official Site)  www.tutorialspoint.com/ruby (Examples provider)  www.rubylearning.com (Useful Tutorials)  www.rubyinstaller.org (Installer for Windows)  www.jetbrains.com/ruby (RubyMine IDE)
  • 32. THANK YOU! Kostas Platis Email : platico.dev@gmail.com Slideshare : www.slideshare.net/platico_dev