From 7ce4d3f1313135c4e2d49a97f9318e99fdfbad41 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 11 Oct 2025 15:26:26 +0300 Subject: Update content for html --- gemfeed/2021-07-04-the-well-grounded-rubyist.html | 5 + ...2025-10-11-the-well-grounded-rubyist-notes.html | 253 ++++++++++++++ gemfeed/atom.xml | 387 +++++++++++++-------- gemfeed/index.html | 1 + 4 files changed, 504 insertions(+), 142 deletions(-) create mode 100644 gemfeed/2025-10-11-the-well-grounded-rubyist-notes.html (limited to 'gemfeed') diff --git a/gemfeed/2021-07-04-the-well-grounded-rubyist.html b/gemfeed/2021-07-04-the-well-grounded-rubyist.html index 6d92a11f..7e5551c5 100644 --- a/gemfeed/2021-07-04-the-well-grounded-rubyist.html +++ b/gemfeed/2021-07-04-the-well-grounded-rubyist.html @@ -133,6 +133,11 @@ Hello World
E-Mail your comments to paul@nospam.buetow.org :-)

+Other Ruby-related posts:
+
+2025-10-11 Key Takeaways from The Well-Grounded Rubyist
+2021-07-04 The Well-Grounded Rubyist (You are currently reading this)
+
Back to the main site

+Home | Markdown | Gemini +

+

Key Takeaways from The Well-Grounded Rubyist


+
+Published at 2025-10-11T15:25:14+03:00
+
+Some time ago, I wrote about my journey into Ruby and how "The Well-Grounded Rubyist" helped me to get a better understanding of the language. I took a lot of notes while reading the book, and I think it's time to share some of them. This is not a comprehensive review, but rather a collection of interesting tidbits and concepts that stuck with me.
+
+My first post about the book.
+
+

The Object Model


+
+One of the most fascinating aspects of Ruby is its object model. The book does a great job of explaining the details.
+
+

Everything is an object (almost)


+
+In Ruby, most things are objects. This includes numbers, strings, and even classes themselves. This has some interesting consequences. For example, you can't use i++ like in C or Java. Integers are immutable objects. 1 is always the same object. 1 + 1 returns a new object, 2.
+
+

The self keyword


+
+There is always a current object, self. If you call a method without an explicit receiver, it's called on self. For example, puts "hello" is actually self.puts "hello".
+
+ +
# At the top level, self is the main object
+p self
+# => main
+p self.class
+# => Object
+
+def foo
+  # Inside a method, self is the object that received the call
+  p self
+end
+
+foo
+# => main
+
+
+This code demonstrates how self changes depending on the context. At the top level, it's main, an instance of Object. When foo is called without a receiver, it's called on main.
+
+

Singleton Methods


+
+You can add methods to individual objects. These are called singleton methods.
+
+ +
obj = "a string"
+
+def obj.shout
+  self.upcase + "!"
+end
+
+p obj.shout
+# => "A STRING!"
+
+obj2 = "another string"
+# obj2.shout would raise a NoMethodError
+
+
+Here, the shout method is only available on the obj object. This is a powerful feature for adding behavior to specific instances.
+
+

Classes are Objects


+
+Classes themselves are objects, instances of the Class class. This means you can create classes dynamically.
+
+ +
MyClass = Class.new do
+  def say_hello
+    puts "Hello from a dynamically created class!"
+  end
+end
+
+instance = MyClass.new
+instance.say_hello
+# => Hello from a dynamically created class!
+
+
+This shows how to create a new class and assign it to a constant. This is what happens behind the scenes when you use the class keyword.
+
+

Control Flow and Methods


+
+The book clarified many things about how methods and control flow work in Ruby.
+
+

case and the === operator


+
+The case statement is more powerful than I thought. It uses the === (threequals or case equality) operator for comparison, not ==. Different classes can implement === in their own way.
+
+ +
# For ranges, it checks for inclusion
+p (1..5) === 3 # => true
+
+# For classes, it checks if the object is an instance of the class
+p String === "hello" # => true
+
+# For regexes, it checks for a match
+p /llo/ === "hello" # => true
+
+def check(value)
+  case value
+  when String
+    "It's a string"
+  when (1..10)
+    "It's a number between 1 and 10"
+  else
+    "Something else"
+  end
+end
+
+p check(5) # => "It's a number between 1 and 10"
+
+
+

Blocks and yield


+
+Blocks are a cornerstone of Ruby. You can pass them to methods to customize their behavior. The yield keyword is used to call the block.
+
+ +
def my_iterator
+  puts "Entering the method"
+  yield
+  puts "Back in the method"
+  yield
+end
+
+my_iterator { puts "Inside the block" }
+# Entering the method
+# Inside the block
+# Back in the method
+# Inside the block
+
+
+This simple iterator shows how yield transfers control to the block. You can also pass arguments to yield and get a return value from the block.
+
+ +
def with_return
+  result = yield(5)
+  puts "The block returned #{result}"
+end
+
+with_return { |n| n * 2 }
+# => The block returned 10
+
+
+This demonstrates passing an argument to the block and using its return value.
+
+

Fun with Data Types


+
+Ruby's core data types are full of nice little features.
+
+

Symbols


+
+Symbols are like immutable strings. They are great for keys in hashes because they are unique and memory-efficient.
+
+ +
# Two strings with the same content are different objects
+p "foo".object_id
+p "foo".object_id
+
+# Two symbols with the same content are the same object
+p :foo.object_id
+p :foo.object_id
+
+# Modern hash syntax uses symbols as keys
+my_hash = { name: "Paul", language: "Ruby" }
+p my_hash[:name] # => "Paul"
+
+
+This code highlights the difference between strings and symbols and shows the convenient hash syntax.
+
+

Arrays and Hashes


+
+Arrays and hashes have a rich API. The %w and %i shortcuts for creating arrays of strings and symbols are very handy.
+
+ +
# Array of strings
+p %w[one two three]
+# => ["one", "two", "three"]
+
+# Array of symbols
+p %i[one two three]
+# => [:one, :two, :three]
+
+
+A quick way to create arrays. You can also retrieve multiple values at once.
+
+ +
arr = [10, 20, 30, 40, 50]
+p arr.values_at(0, 2, 4)
+# => [10, 30, 50]
+
+hash = { a: 1, b: 2, c: 3 }
+p hash.values_at(:a, :c)
+# => [1, 3]
+
+
+The values_at method is a concise way to get multiple elements.
+
+

Final Thoughts


+
+These are just a few of the many things I learned from "The Well-Grounded Rubyist". The book gave me a much deeper appreciation for the language and its design. If you are a Ruby programmer, I highly recommend it. Meanwhile, I also read the book "Programming Ruby 3.3", just I didn't have time to process my notes there yet.
+
+E-Mail your comments to paul@nospam.buetow.org :-)
+
+Other Ruby-related posts:
+
+2021-07-04 The Well-Grounded Rubyist
+
+Back to the main site
+ + + diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index d2f437a8..22dc3466 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,11 +1,255 @@ - 2025-10-02T11:30:14+03:00 + 2025-10-11T15:25:15+03:00 foo.zone feed To be in the .zone! https://foo.zone/ + + Key Takeaways from The Well-Grounded Rubyist + + https://foo.zone/gemfeed/2025-10-11-the-well-grounded-rubyist-notes.html + 2025-10-11T15:25:14+03:00 + + Paul Buetow aka snonux + paul@dev.buetow.org + + Some time ago, I wrote about my journey into Ruby and how 'The Well-Grounded Rubyist' helped me to get a better understanding of the language. I took a lot of notes while reading the book, and I think it's time to share some of them. This is not a comprehensive review, but rather a collection of interesting tidbits and concepts that stuck with me. + +
+

Key Takeaways from The Well-Grounded Rubyist


+
+Some time ago, I wrote about my journey into Ruby and how "The Well-Grounded Rubyist" helped me to get a better understanding of the language. I took a lot of notes while reading the book, and I think it's time to share some of them. This is not a comprehensive review, but rather a collection of interesting tidbits and concepts that stuck with me.
+
+My first post about the book.
+
+

The Object Model


+
+One of the most fascinating aspects of Ruby is its object model. The book does a great job of explaining the details.
+
+

Everything is an object (almost)


+
+In Ruby, most things are objects. This includes numbers, strings, and even classes themselves. This has some interesting consequences. For example, you can't use i++ like in C or Java. Integers are immutable objects. 1 is always the same object. 1 + 1 returns a new object, 2.
+
+

The self keyword


+
+There is always a current object, self. If you call a method without an explicit receiver, it's called on self. For example, puts "hello" is actually self.puts "hello".
+
+ +
# At the top level, self is the main object
+p self
+# => main
+p self.class
+# => Object
+
+def foo
+  # Inside a method, self is the object that received the call
+  p self
+end
+
+foo
+# => main
+
+
+This code demonstrates how self changes depending on the context. At the top level, it's main, an instance of Object. When foo is called without a receiver, it's called on main.
+
+

Singleton Methods


+
+You can add methods to individual objects. These are called singleton methods.
+
+ +
obj = "a string"
+
+def obj.shout
+  self.upcase + "!"
+end
+
+p obj.shout
+# => "A STRING!"
+
+obj2 = "another string"
+# obj2.shout would raise a NoMethodError
+
+
+Here, the shout method is only available on the obj object. This is a powerful feature for adding behavior to specific instances.
+
+

Classes are Objects


+
+Classes themselves are objects, instances of the Class class. This means you can create classes dynamically.
+
+ +
MyClass = Class.new do
+  def say_hello
+    puts "Hello from a dynamically created class!"
+  end
+end
+
+instance = MyClass.new
+instance.say_hello
+# => Hello from a dynamically created class!
+
+
+This shows how to create a new class and assign it to a constant. This is what happens behind the scenes when you use the class keyword.
+
+

Control Flow and Methods


+
+The book clarified many things about how methods and control flow work in Ruby.
+
+

case and the === operator


+
+The case statement is more powerful than I thought. It uses the === (threequals or case equality) operator for comparison, not ==. Different classes can implement === in their own way.
+
+ +
# For ranges, it checks for inclusion
+p (1..5) === 3 # => true
+
+# For classes, it checks if the object is an instance of the class
+p String === "hello" # => true
+
+# For regexes, it checks for a match
+p /llo/ === "hello" # => true
+
+def check(value)
+  case value
+  when String
+    "It's a string"
+  when (1..10)
+    "It's a number between 1 and 10"
+  else
+    "Something else"
+  end
+end
+
+p check(5) # => "It's a number between 1 and 10"
+
+
+

Blocks and yield


+
+Blocks are a cornerstone of Ruby. You can pass them to methods to customize their behavior. The yield keyword is used to call the block.
+
+ +
def my_iterator
+  puts "Entering the method"
+  yield
+  puts "Back in the method"
+  yield
+end
+
+my_iterator { puts "Inside the block" }
+# Entering the method
+# Inside the block
+# Back in the method
+# Inside the block
+
+
+This simple iterator shows how yield transfers control to the block. You can also pass arguments to yield and get a return value from the block.
+
+ +
def with_return
+  result = yield(5)
+  puts "The block returned #{result}"
+end
+
+with_return { |n| n * 2 }
+# => The block returned 10
+
+
+This demonstrates passing an argument to the block and using its return value.
+
+

Fun with Data Types


+
+Ruby's core data types are full of nice little features.
+
+

Symbols


+
+Symbols are like immutable strings. They are great for keys in hashes because they are unique and memory-efficient.
+
+ +
# Two strings with the same content are different objects
+p "foo".object_id
+p "foo".object_id
+
+# Two symbols with the same content are the same object
+p :foo.object_id
+p :foo.object_id
+
+# Modern hash syntax uses symbols as keys
+my_hash = { name: "Paul", language: "Ruby" }
+p my_hash[:name] # => "Paul"
+
+
+This code highlights the difference between strings and symbols and shows the convenient hash syntax.
+
+

Arrays and Hashes


+
+Arrays and hashes have a rich API. The %w and %i shortcuts for creating arrays of strings and symbols are very handy.
+
+ +
# Array of strings
+p %w[one two three]
+# => ["one", "two", "three"]
+
+# Array of symbols
+p %i[one two three]
+# => [:one, :two, :three]
+
+
+A quick way to create arrays. You can also retrieve multiple values at once.
+
+ +
arr = [10, 20, 30, 40, 50]
+p arr.values_at(0, 2, 4)
+# => [10, 30, 50]
+
+hash = { a: 1, b: 2, c: 3 }
+p hash.values_at(:a, :c)
+# => [1, 3]
+
+
+The values_at method is a concise way to get multiple elements.
+
+

Final Thoughts


+
+These are just a few of the many things I learned from "The Well-Grounded Rubyist". The book gave me a much deeper appreciation for the language and its design. If you are a Ruby programmer, I highly recommend it. Meanwhile, I also read the book "Programming Ruby 3.3", just I didn't have time to process my notes there yet.
+
+E-Mail your comments to paul@nospam.buetow.org :-)
+
+Other Ruby-related posts:
+
+2021-07-04 The Well-Grounded Rubyist
+
+Back to the main site
+
+
+
f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments @@ -14027,147 +14271,6 @@ DC on fire:
E-Mail your comments to paul@nospam.buetow.org :-)

-Back to the main site
- - -
- - Gemtexter 2.1.0 - Let's Gemtext again³ - - https://foo.zone/gemfeed/2023-07-21-gemtexter-2.1.0-lets-gemtext-again-3.html - 2023-07-21T10:19:31+03:00 - - Paul Buetow aka snonux - paul@dev.buetow.org - - I proudly announce that I've released Gemtexter version `2.1.0`. What is Gemtexter? It's my minimalist static site generator for Gemini Gemtext, HTML and Markdown, written in GNU Bash. - -
-

Gemtexter 2.1.0 - Let's Gemtext again³


-
-Published at 2023-07-21T10:19:31+03:00
-
-I proudly announce that I've released Gemtexter version 2.1.0. What is Gemtexter? It's my minimalist static site generator for Gemini Gemtext, HTML and Markdown, written in GNU Bash.
-
-https://codeberg.org/snonux/gemtexter
-
-
--=[ typewriters ]=-  1/98
-                                        .-------.
-       .-------.                       _|~~ ~~  |_
-      _|~~ ~~  |_       .-------.    =(_|_______|_)
-    =(_|_______|_)=    _|~~ ~~  |_     |:::::::::|
-      |:::::::::|    =(_|_______|_)    |:::::::[]|
-      |:::::::[]|      |:::::::::|     |o=======.|
-      |o=======.|      |:::::::[]|     `"""""""""`
- jgs  `"""""""""`      |o=======.|
-  mod. by Paul Buetow  `"""""""""`
-
-
-

Table of Contents


-
-
-

Why Bash?


-
-This project is too complex for a Bash script. Writing it in Bash was to try out how maintainable a "larger" Bash script could be. It's still pretty maintainable and helps me try new Bash tricks here and then!
-
-Let's list what's new!
-
-

Switch to GPL3 license


-
-Many (almost all) of the tools and commands (GNU Bash, GMU Sed, GNU Date, GNU Grep, GNU Source Highlight) used by Gemtexter are licensed under the GPL anyway. So why not use the same? This was an easy switch, as I was the only code contributor so far!
-
-

Source code highlighting support


-
-The HTML output now supports source code highlighting, which is pretty neat if your site is about programming. The requirement is to have the source-highlight command, which is GNU Source Highlight, to be installed. Once done, you can annotate a bare block with the language to be highlighted. E.g.:
-
-
- ```bash
- if [ -n "$foo" ]; then
-   echo "$foo"
- fi
- ```
-
-
-The result will look like this (you can see the code highlighting only in the Web version, not in the Geminispace version of this site):
-
- -
if [ -n "$foo" ]; then
-  echo "$foo"
-fi
-
-
-Please run source-highlight --lang-list for a list of all supported languages.
-
-

HTML exact variant


-
-Gemtexter is there to convert your Gemini Capsule into other formats, such as HTML and Markdown. An HTML exact variant can now be enabled in the gemtexter.conf by adding the line declare -rx HTML_VARIANT=exact. The HTML/CSS output changed to reflect a more exact Gemtext appearance and to respect the same spacing as you would see in the Geminispace.
-
-

Use of Hack webfont by default


-
-The Hack web font is a typeface designed explicitly for source code. It's a derivative of the Bitstream Vera and DejaVu Mono lineage, but it features many improvements and refinements that make it better suited to reading and writing code.
-
-The font has distinctive glyphs for every character, which helps to reduce confusion between similar-looking characters. For example, the characters "0" (zero), "O" (capital o), and "o" (lowercase o), or "1" (one), "l" (lowercase L), and "I" (capital i) all have distinct looks in Hack, making it easier to read and understand code at a glance.
-
-Hack is open-source and freely available for use and modification under the MIT License.
-
-

HTML Mastodon verification support


-
-The following link explains how URL verification works in Mastodon:
-
-https://joinmastodon.org/verification
-
-So we have to hyperlink to the Mastodon profile to be verified and also to include a rel='me' into the tag. In order to do that add this to the gemtexter.conf (replace the URI to your Mastodon profile accordingly):
-
- -
declare -xr MASTODON_URI='https://fosstodon.org/@snonux'
-
-
-and add the following into your index.gmi:
-
-
-=> https://fosstodon.org/@snonux Me at Mastodon
-
-
-The resulting line in the HTML output will be something as follows:
-
- -
<a href='https://fosstodon.org/@snonux' rel='me'>Me at Mastodon</a>
-
-
-

More


-
-Additionally, there were a couple of bug fixes, refactorings and overall improvements in the documentation made.
-
-E-Mail your comments to paul@nospam.buetow.org :-)
-
-Other related posts are:
-
-2024-10-02 Gemtexter 3.0.0 - Let's Gemtext again⁴
-2023-07-21 Gemtexter 2.1.0 - Let's Gemtext again³ (You are currently reading this)
-2023-03-25 Gemtexter 2.0.0 - Let's Gemtext again²
-2022-08-27 Gemtexter 1.1.0 - Let's Gemtext again
-2021-06-05 Gemtexter - One Bash script to rule it all
-2021-04-24 Welcome to the Geminispace
-
Back to the main site
diff --git a/gemfeed/index.html b/gemfeed/index.html index bd0c2c77..3ed3dd03 100644 --- a/gemfeed/index.html +++ b/gemfeed/index.html @@ -15,6 +15,7 @@

To be in the .zone!



+2025-10-11 - Key Takeaways from The Well-Grounded Rubyist
2025-10-02 - f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments
2025-09-14 - Bash Golf Part 4
2025-08-15 - Random Weird Things - Part Ⅲ
-- cgit v1.2.3