Ruby Notes for Professionals: Ruby Programmation step by step
- Length: 244 pages
- Edition: 1
- Language: English
- Publication Date: 2021-07-28
- ISBN-10: B09BG8NGLT
- Sales Rank: #0 (See Top 100 Books)
Become an accomplished Ruby programmer by understanding the design principles, best practices, and trade-offs involved in implementation approaches to keep your Ruby applications maintainable in the long term
Key Features
- Understand the design principles behind polished Ruby code and trade-offs between implementation approaches
- Use metaprogramming and DSLs to reduce the amount of code needed without decreasing maintainability
- Learn Ruby web application design principles and strategies for databases, security, and testing
Book Description
Most successful Ruby applications become difficult to maintain over time as the codebase grows in size. Polished Ruby Programming provides you with recommendations and advice for designing Ruby programs that are easy to maintain in the long term.
This book takes you through implementation approaches for many common programming situations, the trade-offs inherent in each approach, and why you may choose to use different approaches in different situations. You’ll start by learning fundamental Ruby programming principles, such as correctly using core classes, class and method design, variable usage, error handling, and code formatting. Moving on, you’ll learn higher-level programming principles, such as library design, use of metaprogramming and domain-specific languages, and refactoring. Finally, you’ll learn principles specific to web application development, such as how to choose a database and web framework, and how to use advanced security features.
By the end of this Ruby programming book, you’ll have gained the skills you need to design robust, high-performance, scalable, and maintainable Ruby applications.
While most code examples and principles discussed in the book apply to all Ruby versions, some examples and principles are specific to Ruby 3.0, the latest release at the time of publication.
What you will learn
- Use Ruby’s core classes and design custom classes effectively
- Explore the principles behind variable usage and method argument choice
- Implement advanced error handling approaches such as exponential backoff
- Design extensible libraries and plugin systems in Ruby
- Use metaprogramming and DSLs to avoid code redundancy
- Implement different approaches to testing and understand their trade-offs
- Discover design patterns, refactoring, and optimization with Ruby
- Explore database design principles and advanced web app security
Who this book is for
If you already know how to program in Ruby and want to learn more about the principles and best practices behind writing maintainable, scalable, optimized, and well-structured Ruby code, then this Ruby book is for you. Intermediate to advanced-level working knowledge of the Ruby programming language is expected to get the most out of this book.
About Chapter 1: Getting started with Ruby Language Section 1 1: Hello World Section 1 2: Hello World as a Self-Executable File—using Shebang (Unix-like operating systems only) Section 1 3: Hello World from IRB Section 1 4: Hello World without source files Section 1 5: Hello World with tk Section 1 6: My First Method Chapter 2: Casting (type conversion) Section 2 1: Casting to a Float Section 2 2: Casting to a String Section 2 3: Casting to an Integer Section 2 4: Floats and Integers Chapter 3: Operators Section 3 1: Operator Precedence and Methods Section 3 2: Case equality operator (===) Section 3 3: Safe Navigation Operator Section 3 4: Assignment Operators Section 3 5: Comparison Operators Chapter 4: Variable Scope and Visibility Section 4 1: Class Variables Section 4 2: Local Variables Section 4 3: Global Variables Section 4 4: Instance Variables Chapter 5: Environment Variables Section 5 1: Sample to get user profile path Chapter 6: Constants Section 6 1: Define a constant Section 6 2: Modify a Constant Section 6 3: Constants cannot be defined in methods Section 6 4: Define and change constants in a class Chapter 7: Special Constants in Ruby Section 7 1: __FILE__ Section 7 2: __dir__ Section 7 3: $PROGRAM_NAME or $0 Section 7 4: $$ Section 7 5: $1, $2, etc Section 7 6: ARGV or $* Section 7 7: STDIN Section 7 8: STDOUT Section 7 9: STDERR Section 7 10: $stderr Section 7 11: $stdout Section 7 12: $stdin Section 7 13: ENV Chapter 8: Comments Section 8 1: Single & Multiple line comments Chapter 9: Arrays Section 9 1: Create Array of Strings Section 9 2: Create Array with Array::new Section 9 3: Create Array of Symbols Section 9 4: Manipulating Array Elements Section 9 5: Accessing elements Section 9 6: Creating an Array with the literal constructor [ ] Section 9 7: Decomposition Section 9 8: Arrays union, intersection and dierence Section 9 9: Remove all nil elements from an array with #compact Section 9 10: Get all combinations / permutations of an array Section 9 11: Inject, reduce Section 9 12: Filtering arrays Section 9 13: #map Section 9 14: Arrays and the splat (*) operator Section 9 15: Two-dimensional array Section 9 16: Turn multi-dimensional array into a one-dimensional (flattened) array Section 9 17: Get unique array elements Section 9 18: Create Array of numbers Section 9 19: Create an Array of consecutive numbers or letters Section 9 20: Cast to Array from any object Chapter 10: Multidimensional Arrays Section 10 1: Initializing a 2D array Section 10 2: Initializing a 3D array Section 10 3: Accessing a nested array Section 10 4: Array flattening Chapter 11: Strings Section 11 1: Dierence between single-quoted and double-quoted String literals Section 11 2: Creating a String Section 11 3: Case manipulation Section 11 4: String concatenation Section 11 5: Positioning strings Section 11 6: Splitting a String Section 11 7: String starts with Section 11 8: Joining Strings Section 11 9: String interpolation Section 11 10: String ends with Section 11 11: Formatted strings Section 11 12: String Substitution Section 11 13: Multiline strings Section 11 14: String character replacements Section 11 15: Understanding the data in a string Chapter 12: DateTime Section 12 1: DateTime from string Section 12 2: New Section 12 3: Add/subtract days to DateTime Chapter 13: Time Section 13 1: How to use the strftime method Section 13 2: Creating time objects Chapter 14: Numbers Section 14 1: Converting a String to Integer Section 14 2: Creating an Integer Section 14 3: Rounding Numbers Section 14 4: Even and Odd Numbers Section 14 5: Rational Numbers Section 14 6: Complex Numbers Section 14 7: Converting a number to a string Section 14 8: Dividing two numbers Chapter 15: Symbols Section 15 1: Creating a Symbol Section 15 2: Converting a String to Symbol Section 15 3: Converting a Symbol to String Chapter 16: Comparable Section 16 1: Rectangle comparable by area Chapter 17: Control Flow Section 17 1: if, elsif, else and end Section 17 2: Case statement Section 17 3: Truthy and Falsy values Section 17 4: Inline if/unless Section 17 5: while, until Section 17 6: Flip-Flop operator Section 17 7: Or-Equals/Conditional assignment operator (||=) Section 17 8: unless Section 17 9: throw, catch Section 17 10: Ternary operator Section 17 11: Loop control with break, next, and redo Section 17 12: return vs next: non-local return in a block Section 17 13: begin, end Section 17 14: Control flow with logic statements Chapter 18: Methods Section 18 1: Defining a method Section 18 2: Yielding to blocks Section 18 3: Default parameters Section 18 4: Optional parameter(s) (splat operator) Section 18 5: Required default optional parameter mix Section 18 6: Use a function as a block Section 18 7: Single required parameter Section 18 8: Tuple Arguments Section 18 9: Capturing undeclared keyword arguments (double splat) Section 18 10: Multiple required parameters Section 18 11: Method Definitions are Expressions Chapter 19: Hashes Section 19 1: Creating a hash Section 19 2: Setting Default Values Section 19 3: Accessing Values Section 19 4: Automatically creating a Deep Hash Section 19 5: Iterating Over a Hash Section 19 6: Filtering hashes Section 19 7: Conversion to and from Arrays Section 19 8: Overriding hash function Section 19 9: Getting all keys or values of hash Section 19 10: Modifying keys and values Section 19 11: Set Operations on Hashes Chapter 20: Blocks and Procs and Lambdas Section 20 1: Lambdas Section 20 2: Partial Application and Currying Section 20 3: Objects as block arguments to methods Section 20 4: Converting to Proc Section 20 5: Blocks Chapter 21: Iteration Section 21 1: Each Section 21 2: Implementation in a class Section 21 3: Iterating over complex objects Section 21 4: For iterator Section 21 5: Iteration with index Section 21 6: Map Chapter 22: Exceptions Section 22 1: Creating a custom exception type Section 22 2: Handling multiple exceptions Section 22 3: Handling an exception Section 22 4: Raising an exception Section 22 5: Adding information to (custom) exceptions Chapter 23: Enumerators Section 23 1: Custom enumerators Section 23 2: Existing methods Section 23 3: Rewinding Chapter 24: Enumerable in Ruby Section 24 1: Enumerable module Chapter 25: Classes Section 25 1: Constructor Section 25 2: Creating a class Section 25 3: Access Levels Section 25 4: Class Methods types Section 25 5: Accessing instance variables with getters and setters Section 25 6: New, allocate, and initialize Section 25 7: Dynamic class creation Section 25 8: Class and instance variables Chapter 26: Inheritance Section 26 1: Subclasses Section 26 2: What is inherited? Section 26 3: Multiple Inheritance Section 26 4: Mixins Section 26 5: Refactoring existing classes to use Inheritance Chapter 27: method_missing Section 27 1: Catching calls to an undefined method Section 27 2: Use with block Section 27 3: Use with parameter Section 27 4: Using the missing method Chapter 28: Regular Expressions and Regex Based Operations Section 28 1: =~ operator Section 28 2: Regular Expressions in Case Statements Section 28 3: Groups, named and otherwise Section 28 4: Quantifiers Section 28 5: Common quick usage Section 28 6: match? - Boolean Result Section 28 7: Defining a Regexp Section 28 8: Character classes Chapter 29: File and I/O Operations Section 29 1: Writing a string to a file Section 29 2: Reading from STDIN Section 29 3: Reading from arguments with ARGV Section 29 4: Open and closing a file Section 29 5: get a single char of input Chapter 30: Ruby Access Modifiers Section 30 1: Instance Variables and Class Variables Section 30 2: Access Controls Chapter 31: Design Patterns and Idioms in Ruby Section 31 1: Decorator Pattern Section 31 2: Observer Section 31 3: Singleton Section 31 4: Proxy Chapter 32: Loading Source Files Section 32 1: Require files to be loaded only once Section 32 2: Automatically loading source files Section 32 3: Loading optional files Section 32 4: Loading files repeatedly Section 32 5: Loading several files Chapter 33: Thread Section 33 1: Accessing shared resources Section 33 2: Basic Thread Semantics Section 33 3: Terminating a Thread Section 33 4: How to kill a thread Chapter 34: Range Section 34 1: Ranges as Sequences Section 34 2: Iterating over a range Section 34 3: Range between dates Chapter 35: Modules Section 35 1: A simple mixin with include Section 35 2: Modules and Class Composition Section 35 3: Module as Namespace Section 35 4: A simple mixin with extend Chapter 36: Introspection in Ruby Section 36 1: Introspection of class Section 36 2: Lets see some examples Chapter 37: Monkey Patching in Ruby Section 37 1: Changing an existing ruby method Section 37 2: Monkey patching a class Section 37 3: Monkey patching an object Section 37 4: Safe Monkey patching with Refinements Section 37 5: Changing a method with parameters Section 37 6: Adding Functionality Section 37 7: Changing any method Section 37 8: Extending an existing class Chapter 38: Recursion in Ruby Section 38 1: Tail recursion Section 38 2: Recursive function Chapter 39: Splat operator (*) Section 39 1: Variable number of arguments Section 39 2: Coercing arrays into parameter list Chapter 40: JSON with Ruby Section 40 1: Using JSON with Ruby Section 40 2: Using Symbols Chapter 41: Pure RSpec JSON API testing Section 41 1: Testing Serializer object and introducing it to Controller Chapter 42: Gem Creation/Management Section 42 1: Gemspec Files Section 42 2: Building A Gem Section 42 3: Dependencies Chapter 43: rbenv Section 43 1: Uninstalling a Ruby Section 43 2: Install and manage versions of Ruby with rbenv Chapter 44: Gem Usage Section 44 1: Installing ruby gems Section 44 2: Gem installation from github/filesystem Section 44 3: Checking if a required gem is installed from within code Section 44 4: Using a Gemfile and Bundler Section 44 5: Bundler/inline (bundler v1 10 and later) Chapter 45: Singleton Class Section 45 1: Introduction Section 45 2: Inheritance of Singleton Class Section 45 3: Singleton classes Section 45 4: Message Propagation with Singleton Class Section 45 5: Reopening (monkey patching) Singleton Classes Section 45 6: Accessing Singleton Class Section 45 7: Accessing Instance/Class Variables in Singleton Classes Chapter 46: Queue Section 46 1: Multiple Workers One Sink Section 46 2: Converting a Queue into an Array Section 46 3: One Source Multiple Workers Section 46 4: One Source - Pipeline of Work - One Sink Section 46 5: Pushing Data into a Queue - #push Section 46 6: Pulling Data from a Queue - #pop Section 46 7: Synchronization - After a Point in Time Section 46 8: Merging Two Queues Chapter 47: Destructuring Section 47 1: Overview Section 47 2: Destructuring Block Arguments Chapter 48: Struct Section 48 1: Creating new structures for data Section 48 2: Customizing a structure class Section 48 3: Attribute lookup Chapter 49: Metaprogramming Section 49 1: Implementing "with" using instance evaluation Section 49 2: send() method Section 49 3: Defining methods dynamically Section 49 4: Defining methods on instances Chapter 50: Dynamic Evaluation Section 50 1: Instance evaluation Section 50 2: Evaluating a String Section 50 3: Evaluating Inside a Binding Section 50 4: Dynamically Creating Methods from Strings Chapter 51: instance_eval Section 51 1: Instance evaluation Section 51 2: Implementing with Chapter 52: Message Passing Section 52 1: Introduction Section 52 2: Message Passing Through Inheritance Chain Section 52 3: Message Passing Through Module Composition Section 52 4: Interrupting Messages Chapter 53: Keyword Arguments Section 53 1: Using arbitrary keyword arguments with splat operator Section 53 2: Using keyword arguments Section 53 3: Required keyword arguments Chapter 54: Truthiness Section 54 1: All objects may be converted to booleans in Ruby Section 54 2: Truthiness of a value can be used in if-else constructs Chapter 55: Implicit Receivers and Understanding Self Section 55 1: There is always an implicit receiver Section 55 2: Keywords change the implicit receiver Section 55 3: When to use self? Chapter 56: Introspection Section 56 1: View an object's methods Section 56 2: View an object's Instance Variables Section 56 3: View Global and Local Variables Section 56 4: View Class Variables Chapter 57: Refinements Section 57 1: Monkey patching with limited scope Section 57 2: Dual-purpose modules (refinements or global patches) Section 57 3: Dynamic refinements Chapter 58: Catching Exceptions with Begin / Rescue Section 58 1: A Basic Error Handling Block Section 58 2: Saving the Error Section 58 3: Checking for Dierent Errors Section 58 4: Retrying Section 58 5: Checking Whether No Error Was Raised Section 58 6: Code That Should Always Run Chapter 59: Command Line Apps Section 59 1: How to write a command line tool to get the weather by zip code Chapter 60: IRB Section 60 1: Starting an IRB session inside a Ruby script Section 60 2: Basic Usage Chapter 61: ERB Section 61 1: Parsing ERB Chapter 62: Generate a random number Section 62 1: 6 Sided die Section 62 2: Generate a random number from a range (inclusive) Chapter 63: Getting started with Hanami Section 63 1: About Hanami Section 63 2: How to install Hanami? Section 63 3: How to start the server? Chapter 64: OptionParser Section 64 1: Mandatory and optional command line options Section 64 2: Default values Section 64 3: Long descriptions Chapter 65: Operating System or Shell commands Section 65 1: Recommended ways to execute shell code in Ruby: Section 65 2: Clasic ways to execute shell code in Ruby: Chapter 66: C Extensions Section 66 1: Your first extension Section 66 2: Working with C Structs Section 66 3: Writing Inline C - RubyInLine Chapter 67: Debugging Section 67 1: Stepping through code with Pry and Byebug Chapter 68: Ruby Version Manager Section 68 1: How to create gemset Section 68 2: Installing Ruby with RVM Appendix A: Installation Section A 1: Installing Ruby macOS Section A 2: Gems Section A 3: Linux - Compiling from source Section A 4: Linux—Installation using a package manager Section A 5: Windows - Installation using installer Section A 6: Linux - troubleshooting gem install Credits You may also like About
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.