Programming Ruby 3.3

Book description

Ruby is one of the most important programming languages in use for web development. It powers the Rails framework, which is the backing of some of the most important sites on the web. The Pickaxe Book, named for the tool on the cover, is the definitive reference on Ruby, a highly-regarded, fully object-oriented programming language. This updated edition is a comprehensive reference on the language itself, with a tutorial on the most important features of Ruby - including pattern matching and Ractors - and describes the language through Ruby 3.3.

Would you like to go from first idea to working code much, much faster? Do you currently spend more time satisfying the compiler instead of your clients or end users? Are you frustrated with demanding languages that seem to get in your way instead of helping you get the work done? Are you using Rails and want to dig deeper into the underlying Ruby language? If so, then we've got a language and book for you!

Ruby is a fully object-oriented language. The combination of the power of a pure object-oriented language with the convenience of a scripting language makes Ruby a favorite tool of programmers that want to get things done quickly and cleanly.

This comprehensive reference manual for Ruby includes a description of the most important standard library modules, built-in classes, and modules. It also includes all the new and changed syntax and semantics introduced through Ruby 3.3, including pattern matching and Ractors, and describes the language through Ruby 3.3.

What You Need:

  • This book assumes you have a basic understanding of object-oriented programming.
  • In general, Ruby programmers tend to favor the the command line for running their code, and they tend to use text editors rather than IDEs.
  • Ruby runs on Windows, Linux, and MacOS.
  • Publisher resources

    View/Submit Errata

    Table of contents

    1.  Preface
      1. Why Ruby?
      2. A Word about Ruby Versions
      3. Notation Conventions
      4. Road Map
      5. Resources
    2.  Acknowledgments
    3. Part I. Facets of Ruby
      1. 1. Getting Started
        1. Installing Ruby
        2. Installing Ruby for Windows
        3. Running Ruby
        4. Creating Ruby Programs
        5. Getting More Information about Ruby
        6. What’s Next
      2. 2. Ruby.new
        1. Ruby Is an Object-Oriented Language
        2. Some Basic Ruby
        3. Arrays and Hashes
        4. Symbols
        5. Control Structures
        6. Regular Expressions
        7. Blocks
        8. Reading and ‘Riting
        9. Command-Line Arguments
        10. Commenting Ruby
        11. What’s Next
      3. 3. Classes, Objects, and Variables
        1. Defining Classes
        2. Objects and Attributes
        3. Classes Working with Other Classes
        4. Specifying Access Control
        5. Variables
        6. Reopening Classes
        7. What’s Next
      4. 4. Collections, Blocks, and Iterators
        1. Arrays
        2. Hashes
        3. Digging
        4. Word Frequency: Using Hashes and Arrays
        5. Blocks and Enumeration
        6. What’s Next
      5. 5. More about Methods
        1. Defining a Method
        2. Calling a Method
        3. What’s Next
      6. 6. Sharing Functionality: Inheritance, Modules, and Mixins
        1. Inheritance and Messages
        2. Modules
        3. Inheritance, Mixins, and Design
        4. What’s Next
      7. 7. Basic Types: Numbers, Strings, and Ranges
        1. Numbers
        2. Strings
        3. Ranges
        4. What’s Next
      8. 8. Regular Expressions
        1. What Regular Expressions Let You Do
        2. Creating and Using Regular Expressions
        3. Regular Expression Patterns
        4. Regular Expression Syntax
        5. What’s Next
      9. 9. Expressions
        1. Operator Expressions
        2. Command Expressions
        3. Assignment
        4. Conditional Execution
        5. Loops and Iterators
        6. Pattern Matching
        7. What’s Next
      10. 10. Exceptions
        1. The Exception Class
        2. Handling Exceptions
        3. Raising Exceptions
        4. Using Catch and Throw
        5. What’s Next
      11. 11. Basic Input and Output
        1. What Is an I/O Object?
        2. Opening and Closing Files
        3. Reading and Writing Files
        4. Talking to Networks
        5. What’s Next
      12. 12. Threads, Fibers, and Ractors
        1. Multithreading with Threads
        2. Running Multiple External Processes
        3. Creating Fibers
        4. Understanding Ractors
        5. What’s Next
      13. 13. Testing Ruby Code
        1. Why Unit Test?
        2. Testing with Minitest
        3. Structuring Tests
        4. Creating Mock Objects in Minitest
        5. Organizing and Running Tests
        6. Testing with RSpec
        7. What’s Next
    4. Part II. Ruby in Its Setting
      1. 14. Ruby from the Command Line
        1. Calling the Ruby Command
        2. Ruby Command-Line Options
        3. Making Your Code an Executable Program
        4. Processing Command-Line Arguments to Your Code
        5. Accessing Environment Variables
        6. Where Ruby Finds Its Libraries
        7. Using the Rake Build Tool
        8. The Build Environment
        9. What’s Next
      2. 15. Ruby Gems
        1. Installing and Managing Gems
        2. Using Bundler to Manage Groups of Gems
        3. Writing and Packaging Your Own Code into Gems
        4. Organizing Your Source Code
        5. Distributing and Installing Your Code
        6. What’s Next
      3. 16. Interactive Ruby
        1. Using irb
        2. Navigating irb
        3. Configuring irb
        4. What’s Next
      4. 17. Debugging Ruby
        1. Printing Things
        2. The Ruby Debugger
        3. Pry
        4. Debugging Performance Issues with Benchmark
        5. What’s Next
      5. 18. Typed Ruby
        1. What’s a Type?
        2. Official Ruby Typing with RBS
        3. Ruby Typing with Sorbet
        4. What’s Next
      6. 19. Documenting Ruby
        1. Documenting with RDoc
        2. Adding RDoc to Ruby Code
        3. Running RDoc
        4. Documenting with YARD
        5. What’s Next
    5. Part III. Ruby Crystallized
      1. 20. Ruby and the Web
        1. Ruby’s Web Utilities
        2. Templating with ERB
        3. Serving Ruby Code to the Web
        4. Ruby in the Browser with Web Assembly
        5. What’s Next
      2. 21. Ruby Style
        1. Written Ruby Style
        2. Using RuboCop
        3. Using Standard
        4. Ruby Style in the Large
        5. Duck Typing
        6. What’s Next
      3. 22. The Ruby Object Model and Metaprogramming
        1. Understanding Objects and Classes
        2. Defining Singleton Methods
        3. Inheritance and Visibility
        4. Modules and Mixins
        5. Metaprogramming Class-Level Macros
        6. Using instance_eval and class_eval
        7. Using Hook Methods
        8. A Metaprogramming Example
        9. Top-Level Execution Environment
        10. What’s Next
      4. 23. Reflection and Object Space
        1. Looking at Objects
        2. Looking at Classes
        3. Calling Methods Dynamically
        4. System Hooks
        5. Tracing Your Program’s Execution
        6. Behind the Curtain: The Ruby VM
        7. Marshaling and Distributed Ruby
        8. What’s Next
    6. Part IV. Ruby Language Reference
      1. 24. Language Reference: Literal Types and Expressions
        1. Source Layout
        2. Ruby Literals
        3. Regular Expressions
        4. Names
        5. Values, Variables, and Constants
        6. Expressions, Conditionals, and Loops
      2. 25. Language Reference: Objects and Classes
        1. Method Definition
        2. Invoking a Method
        3. Aliasing
        4. Defining Classes
        5. Defining Modules
        6. Access Control
        7. Blocks, Closures, and Proc Objects
        8. Exceptions
        9. Catch and Throw
        10. Typed Ruby
    7. Part V. Ruby Library Reference
      1. 26. Library Reference: Core Data Types
        1. Dates and Times
        2. Math
        3. Numbers
        4. Random and SecureRandom
        5. Regexp
        6. Strings
        7. Symbols
      2. 27. Library Reference: Ruby’s Object Model
        1. BasicObject
        2. Class
        3. Comparable
        4. Kernel
        5. Method
        6. Module
        7. Object
      3. 28. Library Reference: Enumerators and Containers
        1. Array
        2. Enumerable
        3. Enumerator
        4. Hash
        5. Set
      4. 29. Library Reference: Input, Output, Files, and Formats
        1. CSV
        2. Dir
        3. File
        4. FileUtils
        5. IO
        6. JSON
        7. Pathname
        8. StringIO
        9. Tempfile
        10. URI
        11. YAML
      5. 30. Library Reference: Ruby on Ruby
        1. Benchmark
        2. Data
        3. Delegator and SimpleDelegator
        4. Logger
        5. ObjectSpace
        6. Observable
        7. OpenStruct
        8. PP
        9. Prism
        10. Ripper
        11. Singleton
        12. Struct
        13. Unbound Method
    8. Part VI. Appendixes
      1. A1. Troubleshooting Ruby
        1. Common Issues
        2. Debugging Tips
      2. A2. I Can’t Look It Up!
      3. A3. Command-Line Basics
        1. The Command Prompt
        2. Folders, Directories, and Navigation
      4. A4. Ruby Runtimes
        1. Just-in-Time Compilers
        2. TruffleRuby
        3. JRuby
        4. mRuby
        5. Other Runtimes
      5. A5. Ruby Changes
        1. Version 2.0
        2. Version 2.1
        3. Version 2.2
        4. Version 2.3
        5. Version 2.4
        6. Version 2.5
        7. Version 2.6
        8. Version 2.7
        9. Version 3.0
        10. Version 3.1
        11. Version 3.2
        12. Version 3.3

    Product information

    • Title: Programming Ruby 3.3
    • Author(s): Noel Rappin, Dave Thomas
    • Release date: January 2024
    • Publisher(s): Pragmatic Bookshelf
    • ISBN: 9781680509823