Chapter 1. Bootstrapping your Ruby literacy
1.1. Basic Ruby language literacy
1.1.1. Installing Ruby and using a text editor
1.1.2. A Ruby syntax survival kit
1.1.3. The variety of Ruby identifiers
1.1.4. Method calls, messages, and Ruby objects
1.1.5. Writing and saving a simple program
1.2. Anatomy of the Ruby installation
1.2.1. The Ruby standard library subdirectory (RbConfig::CONFIG[“rubylibdir”])
1.2.2. The C extensions directory (RbConfig::CONFIG[“archdir”])
1.3. Ruby extensions and programming libraries
1.3.1. Loading external files and extensions
1.3.2. “Load”-ing a file in the default load path
1.4. Out-of-the-box Ruby tools and applications
1.4.1. Interpreter command-line switches
1.4.2. A closer look at interactive Ruby interpretation with irb
Chapter 2. Objects, methods, and local variables
2.1.1. Ruby and object orientation
2.1.2. Creating a generic object
2.2. Crafting an object: the behavior of a ticket
2.2.1. The ticket object, behavior first
2.2.2. Querying the ticket object
2.2.3. Shortening the ticket code via string interpolation
2.2.4. Ticket availability: expressing Boolean state in a method
2.3. The innate behaviors of an object
2.3.1. Identifying objects uniquely with the object_id method
2.3.2. Querying an object’s abilities with the respond_to? method
2.4. A close look at method arguments
2.4.1. Required and optional arguments
2.4.2. Default values for arguments
2.5. Local variables and variable assignment
2.5.1. Variables, objects, and references
2.5.2. References in variable assignment and reassignment
Chapter 3. Organizing objects with classes
3.2. Instance variables and object state
3.3.1. The equal sign (=) in method names
3.4. Attributes and the attr_* method family
3.5. Inheritance and the Ruby class hierarchy
3.5.1. Single inheritance: one to a customer
3.5.2. Object ancestry and the not-so-missing link: the Object class
3.6. Classes as objects and message receivers
3.6.2. How class objects call methods
3.6.3. A singleton method by any other name ...
Chapter 4. Modules and program organization
4.1. Basics of module creation and use
4.1.1. A module encapsulating “stacklikeness”
4.2. Modules, classes, and method lookup
4.2.1. Illustrating the basics of method lookup
4.2.2. Defining the same method more than once
4.2.5. The rules of method lookup summarized
4.2.6. Going up the method search path with super
4.2.7. Inspecting method hierarchies with method and super_method
4.3. The method_missing method
4.4. Class/module design and naming
Chapter 5. The default object (self), scope, and visibility
5.1. Understanding self, the current/default object
5.1.1. Who gets to be self, and where
5.1.2. The top-level self object
5.1.3. Self inside class, module, and method definitions
5.2.1. Global scope and global variables
5.2.3. The interaction between local scope and self
5.3. Deploying method-access rules
5.4. Writing and using top-level methods
Chapter 6. Control-flow techniques
6.1. Conditional code execution
6.1.1. The if keyword and its variants
6.2. Repeating actions with loops
6.2.1. Unconditional looping with the loop method
6.2.2. Conditional looping with the while and until keywords
6.3. Iterators and code blocks
6.3.1. The ingredients of iteration
6.3.3. The anatomy of a method call
6.3.4. Curly braces vs. do/end in code block syntax
6.4. Error handling and exceptions
6.4.1. Raising and rescuing exceptions
6.4.2. The rescue keyword to the rescue!
6.4.3. Debugging with binding.irb
6.4.4. Avoiding NoMethodError with the safe navigation operator
6.4.5. Raising exceptions explicitly
2. Built-in classes and modules
Chapter 7. Built-in essentials
7.1. Ruby’s literal constructors
7.2. Recurrent syntactic sugar
7.3. Bang (!) methods and “danger”
7.4. Built-in and custom to_* (conversion) methods
7.4.1. String conversion: to_s and other methods defined on Object
7.4.2. Array conversion with to_a and the * operator
7.5. Boolean states, Boolean objects, and nil
7.5.1. True and false as states
7.7. Inspecting object capabilities
7.7.1. Listing an object’s methods
Chapter 8. Strings, symbols, and other scalar objects
8.1.2. Basic string manipulation
8.2.1. Chief characteristics of symbols
8.4.1. Instantiating date/time objects
8.4.2. Date/time query methods
Chapter 9. Collection and container objects
9.1. Arrays and hashes in comparison
9.2. Collection handling with arrays
9.2.2. Inserting, retrieving, and removing array elements
9.3.2. Inserting, retrieving, and removing hash pairs
9.3.3. Specifying default hash values and behavior
9.3.4. Combining hashes with other hashes
9.3.7. Hashes as final method arguments
9.3.8. A detour back to argument syntax: named (keyword) arguments
Chapter 10. Collections central: Enumerable and Enumerator
10.1. Gaining enumerability through each
10.2. Enumerable Boolean queries
10.3. Enumerable searching and selecting
10.3.1. Getting the first match with find
10.3.2. Getting all matches with find_all (a.k.a. select) and reject
10.3.3. Selecting on threequal matches with grep
10.3.4. Organizing selection results with group_by and partition
10.4. Element-wise enumerable operations
10.5.2. The each_with_index method (and each.with_index)
10.5.3. The each_slice and each_cons methods
10.7. Strings as quasi-enumerables
10.8.1. Defining sort-order logic with a block
10.9. Enumerators and the next dimension of enumerability
10.9.1. Creating enumerators with a code block
10.9.2. Attaching enumerators to other objects
10.9.3. Implicit creation of enumerators by blockless iterator calls
10.10. Enumerator semantics and uses
10.10.1. How to use an enumerator’s each method
10.10.2. Protecting objects with enumerators
10.11. Enumerator method chaining
10.11.1. Economizing on intermediate objects
10.11.2. Indexing enumerables with with_index
10.11.3. Exclusive-or operations on strings with enumerators
Chapter 11. Regular expressions and regexp-based string operations
11.1. What are regular expressions?
11.2. Writing regular expressions
11.3. Building a pattern in a regular expression
11.3.1. Literal characters in patterns
11.4. Matching, substring captures, and MatchData
11.4.1. Capturing submatches with parentheses
11.4.2. Match success and failure
11.5. Fine-tuning regular expressions with quantifiers, anchors, and modifiers
11.5.1. Constraining matches with quantifiers
11.5.2. Greedy (and non-greedy) quantifiers
11.6. Converting strings and regular expressions to each other
11.7. Common methods that use regular expressions
Chapter 12. File and I/O operations
12.1. How Ruby’s I/O system is put together
12.2.1. The basics of reading from files
12.2.2. Line-based file reading
12.2.3. Byte- and character-based file reading
12.2.4. Seeking and querying file position
12.2.5. Reading files with File class methods
12.3. Querying IO and File objects
12.3.1. Getting information from the File class and the FileTest module
12.4. Directory manipulation with the Dir class
12.5. File tools from the standard library
Chapter 13. Object individuation
13.1. Where the singleton methods are: the singleton class
13.1.1. Dual determination through singleton classes
13.1.2. Examining and modifying a singleton class directly
13.1.3. Singleton classes on the method-lookup path
13.2. Modifying Ruby’s core classes and modules
13.2.1. The risks of changing core functionality
13.2.3. Pass-through overrides
13.3. BasicObject as ancestor and class
Chapter 14. Callable and runnable objects
14.1. Basic anonymous functions: the Proc class
14.1.2. Procs and blocks and how they differ
14.1.3. Block-proc conversions
14.2. Creating functions with lambda and ->
14.4. The eval family of methods
14.4.1. Executing arbitrary strings as code with eval
14.5. Concurrent execution with threads
14.5.1. Killing, stopping, and starting threads
14.5.2. A threaded date server
14.6. Issuing system commands from inside Ruby programs
Chapter 15. Callbacks, hooks, and runtime introspection
15.1.1. Intercepting unrecognized messages with method_missing
15.1.2. Trapping include and prepend operations
15.1.4. Intercepting inheritance with Class#inherited
15.2. Interpreting object capability queries
15.2.1. Listing an object’s non-private methods
15.2.2. Listing private and protected methods
15.3. Introspection of variables and constants
15.5. Callbacks and method inspection in practice
Chapter 16. Ruby and functional programming
16.1. Understanding pure functions
16.1.1. Methods with side effects
16.1.2. Pure functions and referential transparency in Ruby
16.3.2. Kernel#itself and Kernel#yield_self
18.117.137.12