Ruby Notes for Professionals book

    Amazing collection of free programming books

    Collecting
    Free
    Amazing collection of free programming books

    The Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified

    Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners

    https://goalkicker.com/

    Content

    • 1-1
      Content list
    • 1-2
      About
    • 1-3
      Chapter 1: Getting started with Ruby Language
    • 1-4
      Section 1.1: Hello World
    • 1-5
      Section 1.2: Hello World as a Self-Executable File—using Shebang (Unix-like operating systems only)
    • 1-6
      Section 1.3: Hello World from IRB
    • 1-7
      Section 1.4: Hello World without source files
    • 1-8
      Section 1.5: Hello World with tk
    • 1-9
      Section 1.6: My First Method
    • 1-10
      Chapter 2: Casting (type conversion)
    • 1-11
      Section 2.1: Casting to a Float
    • 1-12
      Section 2.2: Casting to a String
    • 1-13
      Section 2.3: Casting to an Integer
    • 1-14
      Section 2.4: Floats and Integers
    • 1-15
      Chapter 3: Operators
    • 1-16
      Section 3.1: Operator Precedence and Methods
    • 1-17
      Section 3.2: Case equality operator (===)
    • 1-18
      Section 3.3: Safe Navigation Operator
    • 1-19
      Section 3.4: Assignment Operators
    • 1-20
      Section 3.5: Comparison Operators
    • 1-21
      Chapter 4: Variable Scope and Visibility
    • 1-22
      Section 4.1: Class Variables
    • 1-23
      Section 4.2: Local Variables
    • 1-24
      Section 4.3: Global Variables
    • 1-25
      Section 4.4: Instance Variables
    • 1-26
      Chapter 5: Environment Variables
    • 1-27
      Section 5.1: Sample to get user profile path
    • 1-28
      Chapter 6: Constants
    • 1-29
      Section 6.1: Define a constant
    • 1-30
      Section 6.2: Modify a Constant
    • 1-31
      Section 6.3: Constants cannot be defined in methods
    • 1-32
      Section 6.4: Define and change constants in a class
    • 1-33
      Chapter 7: Special Constants in Ruby
    • 1-34
      Section 7.1: __FILE__
    • 1-35
      Section 7.2: __dir__
    • 1-36
      Section 7.3: $PROGRAM_NAME or $0
    • 1-37
      Section 7.4: $$
    • 1-38
      Section 7.5: $1, $2, etc
    • 1-39
      Section 7.6: ARGV or $*
    • 1-40
      Section 7.7: STDIN
    • 1-41
      Section 7.8: STDOUT
    • 1-42
      Section 7.9: STDERR
    • 1-43
      Section 7.10: $stderr
    • 1-44
      Section 7.11: $stdout
    • 1-45
      Section 7.12: $stdin
    • 1-46
      Section 7.13: ENV
    • 1-47
      Chapter 8: Comments
    • 1-48
      Section 8.1: Single & Multiple line comments
    • 1-49
      Chapter 9: Arrays
    • 1-50
      Section 9.1: Create Array of Strings
    • 1-51
      Section 9.2: Create Array with Array::new
    • 1-52
      Section 9.3: Create Array of Symbols
    • 1-53
      Section 9.4: Manipulating Array Elements
    • 1-54
      Section 9.5: Accessing elements
    • 1-55
      Section 9.6: Creating an Array with the literal constructor [ ]
    • 1-56
      Section 9.7: Decomposition
    • 1-57
      Section 9.8: Arrays union, intersection and dierence
    • 1-58
      Section 9.9: Remove all nil elements from an array with #compact
    • 1-59
      Section 9.10: Get all combinations / permutations of an array
    • 1-60
      Section 9.11: Inject, reduce
    • 1-61
      Section 9.12: Filtering arrays
    • 1-62
      Section 9.13: #map
    • 1-63
      Section 9.14: Arrays and the splat (*) operator
    • 1-64
      Section 9.15: Two-dimensional array
    • 1-65
      Section 9.16: Turn multi-dimensional array into a one-dimensional (flattened) array
    • 1-66
      Section 9.17: Get unique array elements
    • 1-67
      Section 9.18: Create Array of numbers
    • 1-68
      Section 9.19: Create an Array of consecutive numbers or letters
    • 1-69
      Section 9.20: Cast to Array from any object
    • 1-70
      Chapter 10: Multidimensional Arrays
    • 1-71
      Section 10.1: Initializing a 2D array
    • 1-72
      Section 10.2: Initializing a 3D array
    • 1-73
      Section 10.3: Accessing a nested array
    • 1-74
      Section 10.4: Array flattening
    • 1-75
      Chapter 11: Strings
    • 1-76
      Section 11.1: Dierence between single-quoted and double-quoted String literals
    • 1-77
      Section 11.2: Creating a String
    • 1-78
      Section 11.3: Case manipulation
    • 1-79
      Section 11.4: String concatenation
    • 1-80
      Section 11.5: Positioning strings
    • 1-81
      Section 11.6: Splitting a String
    • 1-82
      Section 11.7: String starts with
    • 1-83
      Section 11.8: Joining Strings
    • 1-84
      Section 11.9: String interpolation
    • 1-85
      Section 11.10: String ends with
    • 1-86
      Section 11.11: Formatted strings
    • 1-87
      Section 11.12: String Substitution
    • 1-88
      Section 11.13: Multiline strings
    • 1-89
      Section 11.14: String character replacements
    • 1-90
      Section 11.15: Understanding the data in a string
    • 1-91
      Chapter 12: DateTime
    • 1-92
      Section 12.1: DateTime from string
    • 1-93
      Section 12.2: New
    • 1-94
      Section 12.3: Add/subtract days to DateTime
    • 1-95
      Chapter 13: Time
    • 1-96
      Section 13.1: How to use the strftime method
    • 1-97
      Section 13.2: Creating time objects
    • 1-98
      Chapter 14: Numbers
    • 1-99
      Section 14.1: Converting a String to Integer
    • 1-100
      Section 14.2: Creating an Integer
    • 1-101
      Section 14.3: Rounding Numbers
    • 1-102
      Section 14.4: Even and Odd Numbers
    • 1-103
      Section 14.5: Rational Numbers
    • 1-104
      Section 14.6: Complex Numbers
    • 1-105
      Section 14.7: Converting a number to a string
    • 1-106
      Section 14.8: Dividing two numbers
    • 1-107
      Chapter 15: Symbols
    • 1-108
      Section 15.1: Creating a Symbol
    • 1-109
      Section 15.2: Converting a String to Symbol
    • 1-110
      Section 15.3: Converting a Symbol to String
    • 1-111
      Chapter 16: Comparable
    • 1-112
      Section 16.1: Rectangle comparable by area
    • 1-113
      Chapter 17: Control Flow
    • 1-114
      Section 17.1: if, elsif, else and end
    • 1-115
      Section 17.2: Case statement
    • 1-116
      Section 17.3: Truthy and Falsy values
    • 1-117
      Section 17.4: Inline if/unless
    • 1-118
      Section 17.5: while, until
    • 1-119
      Section 17.6: Flip-Flop operator
    • 1-120
      Section 17.7: Or-Equals/Conditional assignment operator (||=)
    • 1-121
      Section 17.8: unless
    • 1-122
      Section 17.9: throw, catch
    • 1-123
      Section 17.10: Ternary operator
    • 1-124
      Section 17.11: Loop control with break, next, and redo
    • 1-125
      Section 17.12: return vs. next: non-local return in a block
    • 1-126
      Section 17.13: begin, end
    • 1-127
      Section 17.14: Control flow with logic statements
    • 1-128
      Chapter 18: Methods
    • 1-129
      Section 18.1: Defining a method
    • 1-130
      Section 18.2: Yielding to blocks
    • 1-131
      Section 18.3: Default parameters
    • 1-132
      Section 18.4: Optional parameter(s) (splat operator)
    • 1-133
      Section 18.5: Required default optional parameter mix
    • 1-134
      Section 18.6: Use a function as a block
    • 1-135
      Section 18.7: Single required parameter
    • 1-136
      Section 18.8: Tuple Arguments
    • 1-137
      Section 18.9: Capturing undeclared keyword arguments (double splat)
    • 1-138
      Section 18.10: Multiple required parameters
    • 1-139
      Section 18.11: Method Definitions are Expressions
    • 1-140
      Chapter 19: Hashes
    • 1-141
      Section 19.1: Creating a hash
    • 1-142
      Section 19.2: Setting Default Values
    • 1-143
      Section 19.3: Accessing Values
    • 1-144
      Section 19.4: Automatically creating a Deep Hash
    • 1-145
      Section 19.5: Iterating Over a Hash
    • 1-146
      Section 19.6: Filtering hashes
    • 1-147
      Section 19.7: Conversion to and from Arrays
    • 1-148
      Section 19.8: Overriding hash function
    • 1-149
      Section 19.9: Getting all keys or values of hash
    • 1-150
      Section 19.10: Modifying keys and values
    • 1-151
      Section 19.11: Set Operations on Hashes
    • 1-152
      Chapter 20: Blocks and Procs and Lambdas
    • 1-153
      Section 20.1: Lambdas
    • 1-154
      Section 20.2: Partial Application and Currying
    • 1-155
      Section 20.3: Objects as block arguments to methods
    • 1-156
      Section 20.4: Converting to Proc
    • 1-157
      Section 20.5: Blocks
    • 1-158
      Chapter 21: Iteration
    • 1-159
      Section 21.1: Each
    • 1-160
      Section 21.2: Implementation in a class
    • 1-161
      Section 21.3: Iterating over complex objects
    • 1-162
      Section 21.4: For iterator
    • 1-163
      Section 21.5: Iteration with index
    • 1-164
      Section 21.6: Map
    • 1-165
      Chapter 22: Exceptions
    • 1-166
      Section 22.1: Creating a custom exception type
    • 1-167
      Section 22.2: Handling multiple exceptions
    • 1-168
      Section 22.3: Handling an exception
    • 1-169
      Section 22.4: Raising an exception
    • 1-170
      Section 22.5: Adding information to (custom) exceptions
    • 1-171
      Chapter 23: Enumerators
    • 1-172
      Section 23.1: Custom enumerators
    • 1-173
      Section 23.2: Existing methods
    • 1-174
      Section 23.3: Rewinding
    • 1-175
      Chapter 24: Enumerable in Ruby
    • 1-176
      Section 24.1: Enumerable module
    • 1-177
      Chapter 25: Classes
    • 1-178
      Section 25.1: Constructor
    • 1-179
      Section 25.2: Creating a class
    • 1-180
      Section 25.3: Access Levels
    • 1-181
      Section 25.4: Class Methods types
    • 1-182
      Section 25.5: Accessing instance variables with getters and setters
    • 1-183
      Section 25.6: New, allocate, and initialize
    • 1-184
      Section 25.7: Dynamic class creation
    • 1-185
      Section 25.8: Class and instance variables
    • 1-186
      Chapter 26: Inheritance
    • 1-187
      Section 26.1: Subclasses
    • 1-188
      Section 26.2: What is inherited?
    • 1-189
      Section 26.3: Multiple Inheritance
    • 1-190
      Section 26.4: Mixins
    • 1-191
      Section 26.5: Refactoring existing classes to use Inheritance
    • 1-192
      Chapter 27: method_missing
    • 1-193
      Section 27.1: Catching calls to an undefined method
    • 1-194
      Section 27.2: Use with block
    • 1-195
      Section 27.3: Use with parameter
    • 1-196
      Section 27.4: Using the missing method
    • 1-197
      Chapter 28: Regular Expressions and Regex Based Operations
    • 1-198
      Section 28.1: =~ operator
    • 1-199
      Section 28.2: Regular Expressions in Case Statements
    • 1-200
      Section 28.3: Groups, named and otherwise
    • 1-201
      Section 28.4: Quantifiers
    • 1-202
      Section 28.5: Common quick usage
    • 1-203
      Section 28.6: match? - Boolean Result
    • 1-204
      Section 28.7: Defining a Regexp
    • 1-205
      Section 28.8: Character classes
    • 1-206
      Chapter 29: File and I/O Operations
    • 1-207
      Section 29.1: Writing a string to a file
    • 1-208
      Section 29.2: Reading from STDIN
    • 1-209
      Section 29.3: Reading from arguments with ARGV
    • 1-210
      Section 29.4: Open and closing a file
    • 1-211
      Section 29.5: get a single char of input
    • 1-212
      Chapter 30: Ruby Access Modifiers
    • 1-213
      Section 30.1: Instance Variables and Class Variables
    • 1-214
      Section 30.2: Access Controls
    • 1-215
      Chapter 31: Design Patterns and Idioms in Ruby
    • 1-216
      Section 31.1: Decorator Pattern
    • 1-217
      Section 31.2: Observer
    • 1-218
      Section 31.3: Singleton
    • 1-219
      Section 31.4: Proxy
    • 1-220
      Chapter 32: Loading Source Files
    • 1-221
      Section 32.1: Require files to be loaded only once
    • 1-222
      Section 32.2: Automatically loading source files
    • 1-223
      Section 32.3: Loading optional files
    • 1-224
      Section 32.4: Loading files repeatedly
    • 1-225
      Section 32.5: Loading several files
    • 1-226
      Chapter 33: Thread
    • 1-227
      Section 33.1: Accessing shared resources
    • 1-228
      Section 33.2: Basic Thread Semantics
    • 1-229
      Section 33.3: Terminating a Thread
    • 1-230
      Section 33.4: How to kill a thread
    • 1-231
      Chapter 34: Range
    • 1-232
      Section 34.1: Ranges as Sequences
    • 1-233
      Section 34.2: Iterating over a range
    • 1-234
      Section 34.3: Range between dates
    • 1-235
      Chapter 35: Modules
    • 1-236
      Section 35.1: A simple mixin with include
    • 1-237
      Section 35.2: Modules and Class Composition
    • 1-238
      Section 35.3: Module as Namespace
    • 1-239
      Section 35.4: A simple mixin with extend
    • 1-240
      Chapter 36: Introspection in Ruby
    • 1-241
      Section 36.1: Introspection of class
    • 1-242
      Section 36.2: Lets see some examples
    • 1-243
      Chapter 37: Monkey Patching in Ruby
    • 1-244
      Section 37.1: Changing an existing ruby method
    • 1-245
      Section 37.2: Monkey patching a class
    • 1-246
      Section 37.3: Monkey patching an object
    • 1-247
      Section 37.4: Safe Monkey patching with Refinements
    • 1-248
      Section 37.5: Changing a method with parameters
    • 1-249
      Section 37.6: Adding Functionality
    • 1-250
      Section 37.7: Changing any method
    • 1-251
      Section 37.8: Extending an existing class
    • 1-252
      Chapter 38: Recursion in Ruby
    • 1-253
      Section 38.1: Tail recursion
    • 1-254
      Section 38.2: Recursive function
    • 1-255
      Chapter 39: Splat operator (*)
    • 1-256
      Section 39.1: Variable number of arguments
    • 1-257
      Section 39.2: Coercing arrays into parameter list
    • 1-258
      Chapter 40: JSON with Ruby
    • 1-259
      Section 40.1: Using JSON with Ruby
    • 1-260
      Section 40.2: Using Symbols
    • 1-261
      Chapter 41: Pure RSpec JSON API testing
    • 1-262
      Section 41.1: Testing Serializer object and introducing it to Controller
    • 1-263
      Chapter 42: Gem Creation/Management
    • 1-264
      Section 42.1: Gemspec Files
    • 1-265
      Section 42.2: Building A Gem
    • 1-266
      Section 42.3: Dependencies
    • 1-267
      Chapter 43: rbenv
    • 1-268
      Section 43.1: Uninstalling a Ruby
    • 1-269
      Section 43.2: Install and manage versions of Ruby with rbenv
    • 1-270
      Chapter 44: Gem Usage
    • 1-271
      Section 44.1: Installing ruby gems
    • 1-272
      Section 44.2: Gem installation from github/filesystem
    • 1-273
      Section 44.3: Checking if a required gem is installed from within code
    • 1-274
      Section 44.4: Using a Gemfile and Bundler
    • 1-275
      Section 44.5: Bundler/inline (bundler v1.10 and later)
    • 1-276
      Chapter 45: Singleton Class
    • 1-277
      Section 45.1: Introduction
    • 1-278
      Section 45.2: Inheritance of Singleton Class
    • 1-279
      Section 45.3: Singleton classes
    • 1-280
      Section 45.4: Message Propagation with Singleton Class
    • 1-281
      Section 45.5: Reopening (monkey patching) Singleton Classes
    • 1-282
      Section 45.6: Accessing Singleton Class
    • 1-283
      Section 45.7: Accessing Instance/Class Variables in Singleton Classes
    • 1-284
      Chapter 46: Queue
    • 1-285
      Section 46.1: Multiple Workers One Sink
    • 1-286
      Section 46.2: Converting a Queue into an Array
    • 1-287
      Section 46.3: One Source Multiple Workers
    • 1-288
      Section 46.4: One Source - Pipeline of Work - One Sink
    • 1-289
      Section 46.5: Pushing Data into a Queue - #push
    • 1-290
      Section 46.6: Pulling Data from a Queue - #pop
    • 1-291
      Section 46.7: Synchronization - After a Point in Time
    • 1-292
      Section 46.8: Merging Two Queues
    • 1-293
      Chapter 47: Destructuring
    • 1-294
      Section 47.1: Overview
    • 1-295
      Section 47.2: Destructuring Block Arguments
    • 1-296
      Chapter 48: Struct
    • 1-297
      Section 48.1: Creating new structures for data
    • 1-298
      Section 48.2: Customizing a structure class
    • 1-299
      Section 48.3: Attribute lookup
    • 1-300
      Chapter 49: Metaprogramming
    • 1-301
      Section 49.1: Implementing "with" using instance evaluation
    • 1-302
      Section 49.2: send() method
    • 1-303
      Section 49.3: Defining methods dynamically
    • 1-304
      Section 49.4: Defining methods on instances
    • 1-305
      Chapter 50: Dynamic Evaluation
    • 1-306
      Section 50.1: Instance evaluation
    • 1-307
      Section 50.2: Evaluating a String
    • 1-308
      Section 50.3: Evaluating Inside a Binding
    • 1-309
      Section 50.4: Dynamically Creating Methods from Strings
    • 1-310
      Chapter 51: instance_eval
    • 1-311
      Section 51.1: Instance evaluation
    • 1-312
      Section 51.2: Implementing with
    • 1-313
      Chapter 52: Message Passing
    • 1-314
      Section 52.1: Introduction
    • 1-315
      Section 52.2: Message Passing Through Inheritance Chain
    • 1-316
      Section 52.3: Message Passing Through Module Composition
    • 1-317
      Section 52.4: Interrupting Messages
    • 1-318
      Chapter 53: Keyword Arguments
    • 1-319
      Section 53.1: Using arbitrary keyword arguments with splat operator
    • 1-320
      Section 53.2: Using keyword arguments
    • 1-321
      Section 53.3: Required keyword arguments
    • 1-322
      Chapter 54: Truthiness
    • 1-323
      Section 54.1: All objects may be converted to booleans in Ruby
    • 1-324
      Section 54.2: Truthiness of a value can be used in if-else constructs
    • 1-325
      Chapter 55: Implicit Receivers and Understanding Self
    • 1-326
      Section 55.1: There is always an implicit receiver
    • 1-327
      Section 55.2: Keywords change the implicit receiver
    • 1-328
      Section 55.3: When to use self?
    • 1-329
      Chapter 56: Introspection
    • 1-330
      Section 56.1: View an object's methods
    • 1-331
      Section 56.2: View an object's Instance Variables
    • 1-332
      Section 56.3: View Global and Local Variables
    • 1-333
      Section 56.4: View Class Variables
    • 1-334
      Chapter 57: Refinements
    • 1-335
      Section 57.1: Monkey patching with limited scope
    • 1-336
      Section 57.2: Dual-purpose modules (refinements or global patches)
    • 1-337
      Section 57.3: Dynamic refinements
    • 1-338
      Chapter 58: Catching Exceptions with Begin / Rescue
    • 1-339
      Section 58.1: A Basic Error Handling Block
    • 1-340
      Section 58.2: Saving the Error
    • 1-341
      Section 58.3: Checking for Dierent Errors
    • 1-342
      Section 58.4: Retrying
    • 1-343
      Section 58.5: Checking Whether No Error Was Raised
    • 1-344
      Section 58.6: Code That Should Always Run
    • 1-345
      Chapter 59: Command Line Apps
    • 1-346
      Section 59.1: How to write a command line tool to get the weather by zip code
    • 1-347
      Chapter 60: IRB
    • 1-348
      Section 60.1: Starting an IRB session inside a Ruby script
    • 1-349
      Section 60.2: Basic Usage
    • 1-350
      Chapter 61: ERB
    • 1-351
      Section 61.1: Parsing ERB
    • 1-352
      Chapter 62: Generate a random number
    • 1-353
      Section 62.1: 6 Sided die
    • 1-354
      Section 62.2: Generate a random number from a range (inclusive)
    • 1-355
      Chapter 63: Getting started with Hanami
    • 1-356
      Section 63.1: About Hanami
    • 1-357
      Section 63.2: How to install Hanami?
    • 1-358
      Section 63.3: How to start the server?
    • 1-359
      Chapter 64: OptionParser
    • 1-360
      Section 64.1: Mandatory and optional command line options
    • 1-361
      Section 64.2: Default values
    • 1-362
      Section 64.3: Long descriptions
    • 1-363
      Chapter 65: Operating System or Shell commands
    • 1-364
      Section 65.1: Recommended ways to execute shell code in Ruby:
    • 1-365
      Section 65.2: Clasic ways to execute shell code in Ruby:
    • 1-366
      Chapter 66: C Extensions
    • 1-367
      Section 66.1: Your first extension
    • 1-368
      Section 66.2: Working with C Structs
    • 1-369
      Section 66.3: Writing Inline C - RubyInLine
    • 1-370
      Chapter 67: Debugging
    • 1-371
      Section 67.1: Stepping through code with Pry and Byebug
    • 1-372
      Chapter 68: Ruby Version Manager
    • 1-373
      Section 68.1: How to create gemset
    • 1-374
      Section 68.2: Installing Ruby with RVM
    • 1-375
      Appendix A: Installation
    • 1-376
      Section A.1: Installing Ruby macOS
    • 1-377
      Section A.2: Gems
    • 1-378
      Section A.3: Linux - Compiling from source
    • 1-379
      Section A.4: Linux—Installation using a package manager
    • 1-380
      Section A.5: Windows - Installation using installer
    • 1-381
      Section A.6: Linux - troubleshooting gem install
    • 1-382
      Credits
    • 1-383
      You may also like

    FAQ

    您可以透過手機、平板或是電腦登入 HiSKIO 平台,在【我的學習】>【我的書籍】頁面,選擇想看的電子書。

    Recommendations

    Reviews

    | Collecting

    Sales Plans