About this course

Course type Performance Plus
Course code QARUBYPR
Duration 4 Days

This is a technical course that introduces the Ruby programming language. It is an instructor led presentation and hands on exercises course using MS Windows, but is equally applicable to other platforms such as Linux. The course material covers versions of Ruby from 1.9 onwards, but significant changes from earlier versions will be mentioned.

Target Audience:

This course is suitable for programmers starting new projects in Ruby.


Prerequisites

  • No previous knowledge of Ruby is assumed, although delegates should be familiar with at least one programming language.
  • Experience of a similar language, such as Groovy, Python, Perl or PHP, will be an advantage, as will previous experience of object oriented programming.

Delegates will learn how to

At the end of this course you will be able to:

  • Use the Ruby interactive interpreter to write and run Ruby programs
  • Understand Ruby language elements
  • Exploit the rich library of Ruby libraries and modules
  • Recognize simple and complex variable types and select appropriately
  • Use Ruby operators and built-in methods
  • Understand procedural control flow in Ruby
  • Program file input/output, including persistent data objects.
  • Create well organized and efficient code using classes, methods and modules
  • Use Object Oriented programming techniques in Ruby.
  • Build robust applications with error trapping and reporting
  • Run and control other programs from Ruby
  • Take advantage of multi-core processors with multiprocessing.

Outline

Chapter 1: Introduction to Ruby

  • What is Ruby?
  • Background
    • Ruby versions and implementations
  • Installing Ruby
  • Running Ruby interactively
  • Ruby programs
  • A few definitions
  • Ruby documentation and help
  • Anatomy of a Ruby program
  • Ruby style
  • Comments
  • Delimiters
  • Simple terminal IO
  • Libraries and Classes

Chapter 2: Fundamental Variables

  • Ruby is Object Oriented
  • A class is not a type!
  • Ruby assignments
  • Avoiding alias issues
  • Assignment shortcuts
  • Ruby variables
  • Variable names
  • Ruby literal types
    • Ruby numerics
  • Ruby Arrays introduced
  • Parallel assignments
  • Ranges
  • Ruby Hashes introduced
  • Constants
  • Symbols
  • Type conversion methods
  • A note on Exception Handling
  • Predefined variables

Chapter 3: Basic Flow Control

  • Ruby comparison operators
  • Logical operators
  • What is truth?
    • Ruby conditionals - if
  • Variations on if
  • Ruby conditionals - else and elsif
  • Ternary and defined?
  • Multi-way selection - case/when
  • at_exit methods
  • Unconditional flow control
  • Blocks
    • A conditional is a block

Chapter 4: String Handling

  • Ruby strings
  • Encoding
  • String concatenation
  • Slicing strings
  • String methods
  • String tests
  • Interpolation
  • String formatting
    • sprintf
    • printf
    • % operator
  • String formatting methods
  • String split and Array join

Chapter 5: Collections

  • Ruby types - reminder
  • Ruby Arrays
  • Slicing Arrays
  • Stack and deque type operations
  • Adding items to an Array
  • Removing items from an Array
  • Sorting
  • Array set operations
  • Array methods
  • Ruby Hashes
  • Hash keys
  • Testing and merging hashes
  • Sets

Chapter 6: Loops and iterators

  • Code blocks
  • Passing parameters to blocks
  • Using blocks
  • While loops
  • Variations on while
  • Loop control statements
  • The basic loop
  • For loops
  • Counting loops
  • Enumerable
  • Map and grep

Chapter 7: Regular Expressions

  • Ruby regular expressions
  • Elementary extended RE meta-characters
  • Regular expression objects
  • Pattern match syntax
  • Regular expression substitution
  • Matching alternatives
  • Anchors
  • Class shortcuts
  • Options
  • Quantifiers
  • Minimal matches
  • Back-references
  • Side-effect variables
  • Sub-patterns and MatchData
  • Global matches - scan
  • Using gsub with a Hash

Chapter 8: Data Storage and File Handling

  • Standard streams
  • IO objects and methods
  • Reading files
  • Filter Programs - ARGF
  • Command-line ARGF processing
  • Binary mode
  • Writing to files
  • Random access
  • File objects
  • Ruby object persistence
    • Marshal
    • YAML

Chapter 9: Methods and Friends

  • Methods, Senders, and Receivers
  • Ruby methods
  • Scope
  • Arguments and Parameters
    • Assigning default values to parameters
    • Argument packing
  • Keyword arguments
  • Returning objects from a method
  • Blocks and Procs
  • yield
  • Lambda methods
  • Passing methods as parameters
  • Closures, and scope revisited

Chapter 10: Classes and OOP

  • Using classes and objects
  • Defining classes and attributes
  • A simple class
  • Method shortcuts
  • Method= or attribute?
  • Class variables and methods
  • Ruby inheritance
    • Accessing superclass
    • Access control
    • Class level instance
  • Conversion protocols
  • Operator overloading
  • Coercions

Chapter 11: Modules and Libraries

  • What is a module?
  • Modules and classes compared
  • Module-level methods
  • Importing modules
  • Module access levels
  • Library files
  • How does Ruby find a library?
  • Including a module within a class - Mixins
  • Including a class within a module
  • Extending
  • Library documentation - Rdoc

Chapter 12: Error Handling and Exceptions

  • Exception handling
  • Exception syntax
  • The Ruby exception hierarchy
  • Multiple exceptions
  • The ensure block
  • The raise statement
  • Creating our own Exceptions
  • Retry
  • Catch and throw
  • Backtracing

Chapter 13: Multitasking

  • Multitasking mechanisms
  • Running a process from Ruby
    • `Back-ticks`
    • The system method
    • Passing data through a pipe - popen
    • Asynchronous processes - spawn
  • Processes and threads
  • Very basic threads in Ruby
  • The Fork/Join threading model
  • Using Threads with variables
  • Synchronization objects in threading
  • Simple use of Mutex
  • Queue objects
  • Exception issues
  • Ruby thread implementations
  • The trouble with threads
  • When to use threads

Chapter 14: The Ruby Standard Library

  • The Ruby Standard Library
  • Bundled Modules and Classes
  • RBConfig module
  • Unit testing
  • Coverage
  • Libraries for Web and email access
  • PrettyPrint and PP
  • Fiddle
  • FileUtils
  • Other modules - RubyGems.org
  • activesupport

Chapter 15: The Way Ahead

  • Now you are a Rubyist
  • Some books
  • Web links
Performance Plus

4 Days

Duration

This course is authored by QA

Delivery Method

Delivery method

Classroom / Attend from Anywhere

Receive classroom training at one of our nationwide training centres, or attend remotely via web access from anywhere.

Find dates and prices

Online booking is currently not available for this course, to find out more please call us on 0345 074 7998 or email us at info@qa.com to discuss how we can help.

Trusted, awarded and accredited

Fully accredited to ensure we provide the highest possible standards in learning

All third party trademark rights acknowledged.