Ruby Programming, 2ed: The Well-Grounded Rubyist

David A. Black

ISBN: 9789351198246

536 pages

INR 649

Description

Ruby programming, The Well-Grounded Rubyist, Second Edition is a beautifully written tutorial that begins with your first Ruby program and goes on to explore sophisticated topics like callable objects, reflection and threading. The book concentrates on the language, preparing you to use Ruby in any way you choose. This second edition includes coverage of new Ruby features such as keyword arguments, lazy enumerators and Module#prepend, along with updated information on new and changed core classes and methods.

 

Part 1 Ruby Foundations

 

Chapter 1 Bootstrapping your Ruby literacy

  • Basic Ruby language literacy
  • Anatomy of the Ruby installation
  • Ruby extensions and programming libraries
  • Out-of-the-box Ruby tools and applications


Chapter 2 Objects, methods and local variables

  • Talking to objects
  • Crafting an object: The behavior of a ticket
  • The innate behaviors of an object
  • A close look at method arguments
  • Local variables and variable assignment


Chapter 3 Organizing objects with classes

  • Classes and instances
  • Instance variables and object state
  • Setter methods
  • Attributes and the attr_* method family
  • Inheritance and the Ruby class hierarchy
  • Classes as objects and message receivers
  • Constants up close
  • Nature vs. nurture in Ruby objects


Chapter 4 Modules and program organization

  • Basics of module creation and use
  • Modules, classes and method lookup
  • The method_missing method
  • Class/module design and naming


Chapter 5 The default object (self), scope and visibility

  • Understanding self, the current / default object
  • Determining scope
  • Deploying method-access rules
  • Writing and using top-level methods

 

Chapter 6 Control-flow techniques

  • Conditional code execution
  • Repeating actions with loops
  • Iterators and code blocks
  • Error handling and exceptions

 

Part 2 Built-in classes and modules

 

Chapter 7 Built-in essentials

  • Ruby’s literal constructors
  • Recurrent syntactic sugar
  • Bang (!) methods and “danger”
  • Built-in and custom to_* (conversion) methods
  • Boolean states, Boolean objects and nil
  • Comparing two objects
  • Inspecting object capabilities

 

Chapter 8 Strings, symbols and other scalar objects

  • Working with strings
  • Symbols and their uses
  • Numerical objects
  • Times and dates

 

Chapter 9 Collection and container objects

  • Arrays and hashes in comparison
  • Collection handling with arrays
  • Hashes
  • Ranges
  • Sets

 

Chapter 10 Collections central: Enumerable and Enumerator

  • Gaining enumerability through each
  • Enumerable Boolean queries
  • Enumerable searching and selecting
  • Element-wise enumerable operations
  • Relatives of each
  • The map method
  • Strings as quasi-enumerables
  • Sorting enumerables
  • Enumerators and the next dimension of enumerability
  • Enumerator semantics and uses
  • Enumerator method chaining
  • Lazy enumerators

 

Chapter 11 Regular expressions and regexp-based string operations

  • What are regular expressions?
  • Writing regular expressions
  • Building a pattern in a regular expression
  • Matching, substring captures and MatchData
  • Fine-tuning regular expressions with quantifiers, anchors and modifiers
  • Converting strings and regular expressions to each other
  • Common methods that use regular expressions

 

Chapter 12 File and I/O operations

  • How Ruby’s I/O system is put together
  • Basic file operations
  • Querying IO and File objects
  • Directory manipulation with the Dir class
  • File tools from the standard library

 

Part 3 Ruby dynamics

 

Chapter 13 Object individuation

  • Where the singleton methods are: The singleton class
  • Modifying Ruby’s core classes and modules
  • BasicObject as ancestor and class

 

Chapter 14 Callable and runnable objects

  • Basic anonymous functions: The Proc class
  • Creating functions with lambda and ->
  • Methods as objects
  • The eval family of methods
  • Parallel execution with threads
  • Issuing system commands from inside Ruby programs

 

Chapter 15 Callbacks, hooks and runtime introspection

  • Callbacks and hooks
  • Interpreting object capability queries
  • Introspection of variables and constants
  • Tracing execution
  • Callbacks and method inspection in practice

 

Summary