SlideShare a Scribd company logo
1 of 22
Ruby
Week 2
Agenda
Homework Review and Submission

Git Branches

The Ruby Language

Ruby Gems (grb)

IRB: String objects, String Class,
Variables, puts/gets

Making Our Own Objects
HomeWork Review


Questions.txt

strings_and_rspec_spec.rb

Send a Pull Request to UWE-Ruby/
RubyFall2012
Git Review


GitHub

forks and repos (remote & local)

branches (DeMo!)
Rspec Review


Code that Tests Code!!

Describe a feature, set an
expectation.

Red-Green-Refactor
Ruby

Everything is an Object!

Type Doesn’t matter! (respond_to?)

Speaking Ruby : Interpreter Needed!

  MRI, YARV, JRuby
Ruby Gems

Packaged Ruby Code

Open Source

iPhone user:   “There’s an app for that!”


Ruby programer:    “There’s a gem for that!”
GRB

Git Remote Branch

Ruby Gem to help with git!

Combines remote branch steps into
one!

DeMo!
IRB

Interactive Ruby!

Our Ruby Interpreter!

We speak ruby, it translates!

Understand Ruby code, evaluates it,
gives us the result (inspect)
Ruby

Everything evaluates to something

nil is NULL or nothing or Not Set

Every Object respond_to? inspect

  => true
Objects

Ruby: everything is an object

  Everything is an instance of a
  class

Ruby knows about certain classes of
things: Standard Library
String

String class : part of the standard
library

How Ruby understands text

Instances

  String.new or ‘’ or “”    or Q%[] or
  q%[]
String Class

http://www.ruby-doc.org/core-1.9.3/
String.html

Methods : Messages we can send, what
an instance will respond to

Chomp, *, +, include?, upcase
Variables


Named location

Points to something

Contents Can Change
String Interpolation



 my_name = “Renée”

 “Hello #{my_name}”
puts / gets

put string

get string

puts “Hello World”

user_input = gets

user_input = gets.chomp
Mad-Libs!

noun = gets.chomp

adjective = gets.chomp

verb_past_tense = gets.chomp

“The #{adjective} #{noun}
#{verb_past_tense} past the
graveyard”
Ruby Scripts



mad_libs.rb

ruby mad_libs.rb
Making Objects



Tell Ruby About Something New!

A new class of stuff!
What is a Book



All Books have....??
Defining New Classes

 Initialize

 attributes / readers and writers

 Scope

   Instance variables

   Instance methods
Homework



Reading and Simon Says Spec

More Related Content

What's hot

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyMark Menard
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotationsmametter
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understandingmametter
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLAlex Sharp
 
Enjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfEnjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfmametter
 
A Test Code Generator for RSpec Users
A Test Code Generator for RSpec UsersA Test Code Generator for RSpec Users
A Test Code Generator for RSpec UsersKazuhiro Sera
 
Iron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NETIron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NETKristian Kristensen
 
Getting started with typescript and angular 2
Getting started with typescript  and angular 2Getting started with typescript  and angular 2
Getting started with typescript and angular 2Knoldus Inc.
 
Type Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesType Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesmametter
 
Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3mametter
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hoodcowboyd
 
A Plan towards Ruby 3 Types
A Plan towards Ruby 3 TypesA Plan towards Ruby 3 Types
A Plan towards Ruby 3 Typesmametter
 
Ruby introductions
Ruby introductionsRuby introductions
Ruby introductionsBinh Bui
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language PerformanceKevin Hazzard
 
Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Fuqiang Wang
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in PharoMarcus Denker
 
Actor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka FundamentalsActor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka FundamentalsNgoc Dao
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-partsFuqiang Wang
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with javaLiviu Tudor
 

What's hot (20)

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understanding
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSL
 
Enjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfEnjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProf
 
A Test Code Generator for RSpec Users
A Test Code Generator for RSpec UsersA Test Code Generator for RSpec Users
A Test Code Generator for RSpec Users
 
Iron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NETIron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NET
 
OOPS Advanced
OOPS AdvancedOOPS Advanced
OOPS Advanced
 
Getting started with typescript and angular 2
Getting started with typescript  and angular 2Getting started with typescript  and angular 2
Getting started with typescript and angular 2
 
Type Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signaturesType Profiler: An Analysis to guess type signatures
Type Profiler: An Analysis to guess type signatures
 
Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hood
 
A Plan towards Ruby 3 Types
A Plan towards Ruby 3 TypesA Plan towards Ruby 3 Types
A Plan towards Ruby 3 Types
 
Ruby introductions
Ruby introductionsRuby introductions
Ruby introductions
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language Performance
 
Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Continuations in scala (incomplete version)
Continuations in scala (incomplete version)
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in Pharo
 
Actor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka FundamentalsActor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka Fundamentals
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with java
 

Similar to Week2

Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroadJim Jones
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoadwebuploader
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010ssoroka
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Rormyuser
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approachFelipe Schmitt
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorialknoppix
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Muhammad Haseeb Shahid
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Hiroshi SHIBATA
 
Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1James Thompson
 
2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rbawwaiid
 
Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Brian Sam-Bodden
 
On the path to become a jr. developer short version
On the path to become a jr. developer short versionOn the path to become a jr. developer short version
On the path to become a jr. developer short versionAntonelo Schoepf
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovMichael Kimathi
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_pythontutorialsruby
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_pythontutorialsruby
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 

Similar to Week2 (20)

Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1Learn Ruby 2011 - Session 1
Learn Ruby 2011 - Session 1
 
Ruby Metaprogramming 08
Ruby Metaprogramming 08Ruby Metaprogramming 08
Ruby Metaprogramming 08
 
2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb
 
Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008
 
On the path to become a jr. developer short version
On the path to become a jr. developer short versionOn the path to become a jr. developer short version
On the path to become a jr. developer short version
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
 
Rubyon Rails
Rubyon RailsRubyon Rails
Rubyon Rails
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 

More from reneedv

Nginx caching
Nginx cachingNginx caching
Nginx cachingreneedv
 
Fill Up your Bookshelves!
Fill Up your Bookshelves! Fill Up your Bookshelves!
Fill Up your Bookshelves! reneedv
 
Dealing with Legacy <del>Code</del> People
Dealing with Legacy <del>Code</del> PeopleDealing with Legacy <del>Code</del> People
Dealing with Legacy <del>Code</del> Peoplereneedv
 
Whose Wife Are You?
Whose Wife Are You?Whose Wife Are You?
Whose Wife Are You?reneedv
 
How I Learned to Smell Code
How I Learned to Smell CodeHow I Learned to Smell Code
How I Learned to Smell Codereneedv
 
RailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop IntroRailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop Introreneedv
 

More from reneedv (14)

Nginx caching
Nginx cachingNginx caching
Nginx caching
 
Week10
Week10Week10
Week10
 
Week9
Week9Week9
Week9
 
Week7
Week7Week7
Week7
 
Week6
Week6Week6
Week6
 
Week5
Week5Week5
Week5
 
Week4
Week4Week4
Week4
 
Week3
Week3Week3
Week3
 
Week1
Week1Week1
Week1
 
Fill Up your Bookshelves!
Fill Up your Bookshelves! Fill Up your Bookshelves!
Fill Up your Bookshelves!
 
Dealing with Legacy <del>Code</del> People
Dealing with Legacy <del>Code</del> PeopleDealing with Legacy <del>Code</del> People
Dealing with Legacy <del>Code</del> People
 
Whose Wife Are You?
Whose Wife Are You?Whose Wife Are You?
Whose Wife Are You?
 
How I Learned to Smell Code
How I Learned to Smell CodeHow I Learned to Smell Code
How I Learned to Smell Code
 
RailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop IntroRailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop Intro
 

Week2

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n