SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
Introduction to Ruby
      Andrew Liu
Ruby is…
• Designed by Yukihiro Matsumoto (松本行弘)
  – "I wanted a scripting language that was more
    powerful than Perl, and more object-
    oriented than Python. That's why I decided to
    design my own language“
• An object-oriented scripting language
• Easy to learn!
Philosophy
• Often people, especially computer engineers, focus
  on the machines. They think, "By doing this, the
  machine will run faster. By doing this, the machine
  will run more effectively. By doing this, the machine
  will something something something."
• They are focusing on machines. But in fact we need
  to focus on humans, on how humans care about
  doing programming or operating the application of
  the machines. We are the masters. They are the
  slaves.
Naming Convention
• CamelCase
  – Class names, module names
• ALLCAPITAL
  – Constants
• words_with_underscore
  – Method names, variable names
• $ prefix
  – Global variables
Everything is an object!
Strings
String Methods
Array
What if I want to reverse the array?
                        http://ruby-doc.org/core/
Range
Hash
Block
How does it work?
More About Class
More About Class
Class
• Variable
  – @@ prefix: Shared by all class instances
  – @ prefix: Contains instances information
  – No prefix: normal variables
• Methods
  – self. Prefix: Class methods, as known as static
    method
  – No prefix: Instance methods, must be called with
    a instance
Creating Instance
Flow Control
Cases
While
For
Resources
• Programming Ruby (Bible)
  – http://www.ruby-
    doc.org/docs/ProgrammingRuby/
• Ruby API Document
  – http://ruby-doc.org/core/
• TryRuby
  – http://tryruby.org/
• Ruby Warrior
  – https://github.com/ryanb/ruby-warrior

Mais conteúdo relacionado

Mais procurados

Ruby in prijatelji
Ruby in prijateljiRuby in prijatelji
Ruby in prijateljiOto Brglez
 
Power of introspection
Power of introspectionPower of introspection
Power of introspectionJoseph Jeffrey
 
JavaScript: Creative Coding for Browsers
JavaScript: Creative Coding for BrowsersJavaScript: Creative Coding for Browsers
JavaScript: Creative Coding for Browsersnoweverywhere
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPresskeithdevon
 
Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Vibhawa Nirmal
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGentkevinvw
 
Round trip - What changes & what doesn't
Round trip - What changes & what doesn'tRound trip - What changes & what doesn't
Round trip - What changes & what doesn'tAsher Barak
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
Introduction to Browser DOM
Introduction to Browser DOMIntroduction to Browser DOM
Introduction to Browser DOMSiva Arunachalam
 

Mais procurados (10)

Ruby in prijatelji
Ruby in prijateljiRuby in prijatelji
Ruby in prijatelji
 
Power of introspection
Power of introspectionPower of introspection
Power of introspection
 
JavaScript: Creative Coding for Browsers
JavaScript: Creative Coding for BrowsersJavaScript: Creative Coding for Browsers
JavaScript: Creative Coding for Browsers
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPress
 
Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Round trip - What changes & what doesn't
Round trip - What changes & what doesn'tRound trip - What changes & what doesn't
Round trip - What changes & what doesn't
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
Introduction to Browser DOM
Introduction to Browser DOMIntroduction to Browser DOM
Introduction to Browser DOM
 

Destaque

Rochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to RubyRochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to RubyJason Morrison
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyPaul Regnart
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
Introduction to Ruby & Modern Programming
Introduction to Ruby & Modern ProgrammingIntroduction to Ruby & Modern Programming
Introduction to Ruby & Modern ProgrammingChristos Sotirelis
 
Ruby An Introduction
Ruby An IntroductionRuby An Introduction
Ruby An IntroductionShrinivasan T
 

Destaque (6)

Rochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to RubyRochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to Ruby
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Introduction to Ruby & Modern Programming
Introduction to Ruby & Modern ProgrammingIntroduction to Ruby & Modern Programming
Introduction to Ruby & Modern Programming
 
Ruby An Introduction
Ruby An IntroductionRuby An Introduction
Ruby An Introduction
 

Semelhante a Introduction to ruby

Python intro and competitive programming
Python intro and competitive programmingPython intro and competitive programming
Python intro and competitive programmingSuraj Shah
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approachFelipe Schmitt
 
Snakes on the Web; Developing web applications in python
Snakes on the Web; Developing web applications in pythonSnakes on the Web; Developing web applications in python
Snakes on the Web; Developing web applications in pythonNaail AbdulRahman
 
Natural Language Processing Tools for the Digital Humanities
Natural Language Processing Tools for the Digital HumanitiesNatural Language Processing Tools for the Digital Humanities
Natural Language Processing Tools for the Digital HumanitiesXiang Li
 
Hunting for anglerfish in datalakes
Hunting for anglerfish in datalakesHunting for anglerfish in datalakes
Hunting for anglerfish in datalakesDominic Egger
 
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)Databricks
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat
 
Code reviews
Code reviewsCode reviews
Code reviewsRoger Xia
 
West Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
West Coast DevCon 2014: Programming in UE4 - A Quick Orientation for CodersWest Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
West Coast DevCon 2014: Programming in UE4 - A Quick Orientation for CodersGerke Max Preussner
 
Why i love ruby than x
Why i love ruby than xWhy i love ruby than x
Why i love ruby than xSamnang Chhun
 
What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?Barry Jones
 
Not Everything is an Object - Rocksolid Tour 2013
Not Everything is an Object  - Rocksolid Tour 2013Not Everything is an Object  - Rocksolid Tour 2013
Not Everything is an Object - Rocksolid Tour 2013Gary Short
 
Natural Language Search in Solr
Natural Language Search in SolrNatural Language Search in Solr
Natural Language Search in SolrTommaso Teofili
 

Semelhante a Introduction to ruby (20)

Python intro and competitive programming
Python intro and competitive programmingPython intro and competitive programming
Python intro and competitive programming
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
 
Snakes on the Web; Developing web applications in python
Snakes on the Web; Developing web applications in pythonSnakes on the Web; Developing web applications in python
Snakes on the Web; Developing web applications in python
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Ruby and Security
Ruby and SecurityRuby and Security
Ruby and Security
 
Natural Language Processing Tools for the Digital Humanities
Natural Language Processing Tools for the Digital HumanitiesNatural Language Processing Tools for the Digital Humanities
Natural Language Processing Tools for the Digital Humanities
 
Yapc2012
Yapc2012Yapc2012
Yapc2012
 
Hunting for anglerfish in datalakes
Hunting for anglerfish in datalakesHunting for anglerfish in datalakes
Hunting for anglerfish in datalakes
 
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
 
Taming Text
Taming TextTaming Text
Taming Text
 
Apache Lucene 4
Apache Lucene 4Apache Lucene 4
Apache Lucene 4
 
Bioinformatica p1-perl-introduction
Bioinformatica p1-perl-introductionBioinformatica p1-perl-introduction
Bioinformatica p1-perl-introduction
 
Code reviews
Code reviewsCode reviews
Code reviews
 
West Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
West Coast DevCon 2014: Programming in UE4 - A Quick Orientation for CodersWest Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
West Coast DevCon 2014: Programming in UE4 - A Quick Orientation for Coders
 
Why i love ruby than x
Why i love ruby than xWhy i love ruby than x
Why i love ruby than x
 
What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?
 
Not Everything is an Object - Rocksolid Tour 2013
Not Everything is an Object  - Rocksolid Tour 2013Not Everything is an Object  - Rocksolid Tour 2013
Not Everything is an Object - Rocksolid Tour 2013
 
Natural Language Search in Solr
Natural Language Search in SolrNatural Language Search in Solr
Natural Language Search in Solr
 
Python1
Python1Python1
Python1
 

Introduction to ruby

  • 1. Introduction to Ruby Andrew Liu
  • 2. Ruby is… • Designed by Yukihiro Matsumoto (松本行弘) – "I wanted a scripting language that was more powerful than Perl, and more object- oriented than Python. That's why I decided to design my own language“ • An object-oriented scripting language • Easy to learn!
  • 3. Philosophy • Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something." • They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.
  • 4.
  • 5. Naming Convention • CamelCase – Class names, module names • ALLCAPITAL – Constants • words_with_underscore – Method names, variable names • $ prefix – Global variables
  • 10. What if I want to reverse the array? http://ruby-doc.org/core/
  • 11.
  • 12. Range
  • 13. Hash
  • 14. Block
  • 15. How does it work?
  • 18. Class • Variable – @@ prefix: Shared by all class instances – @ prefix: Contains instances information – No prefix: normal variables • Methods – self. Prefix: Class methods, as known as static method – No prefix: Instance methods, must be called with a instance
  • 20.
  • 22. Cases
  • 23. While
  • 24. For
  • 25. Resources • Programming Ruby (Bible) – http://www.ruby- doc.org/docs/ProgrammingRuby/ • Ruby API Document – http://ruby-doc.org/core/ • TryRuby – http://tryruby.org/ • Ruby Warrior – https://github.com/ryanb/ruby-warrior