โจ Check out this must-read post from Hacker News ๐
๐ Category:
๐ก Key idea:
Yesterday I hosted Novemberโs Hotwire Native Office Hours.

Hotwire Native Office Hours
Every month I host an hour long Zoom session for developers to directly ask me questions. The topics range greatly: some folks are just getting started and others are asking very specific, advanced questions.
This month we covered everything from registering bridge components to native vs. web-based tabs to authenticating Apple Watch apps! Itโs really fun to see what folks are working on in the Hotwire Native space.
During the session I shared some code I wrote to figure out what version a Hotwire Native app is running. The app sends the version in the user agent (e.g. v1.2.3) and then I parse it with the following Ruby class on the server:
class AppVersion
include Comparable
attr_reader :major, :minor, :patch
def initialize(version_string)
parts = version_string.to_s.split(โ.โ).map(&:to_i)
@major, @minor, @patch = parts[0] || 0, parts[1] || 0, parts[2] || 0
end
def <=>(other)
[major, minor, patch] <=> [other.major, other.minor, other.patch]
end
def to_s
โ#โก.#Tell us your thoughts in comments!.#๐ฌโ
end
end
And it works great! I use this throughout my apps to feature flag code based on which version the app is running.
But someone brought up something even better: Gem::Version. This class accomplishes the same goal: โprocess string versions into comparable valuesโ.
irb(main)> Gem::Version.new("1.2.3") > Gem::Version.new("1.2.2")
=> true
irb(main)> Gem::Version.new("2.0") > Gem::Version.new("1.2.2")
=> true
It can even compare prerelease versions, like alphas or betas.
irb(main)> Gem::Version.new("2.0.b1") > Gem::Version.new("1.9")
=> true
irb(main)> Gem::Version.new("2.0") > Gem::Version.new("2.0.b1")
=> true
The big advantage this class has over my implementation is that itโs built into Ruby!
Itโs not even a Rails dependency but part of the standard Ruby library. Internally, this class is used to compare version numbers when parsing your Gemfile. Check out the documentation, I picked up a few things on semantic versioning when reading it.
Iโve already replaced my AppVersion class with Gem::Version. But it makes me wonder what other Ruby/Rails features I donโt know about and am implementing on my own!
I never would have learned about Gem::Version if it wasnโt for someone bringing it up during office hours. Iโd still be using my custom (and most likely buggy!) AppVersion implementationโฆย like a chump. ๐
But seriously, this is why I love connecting with folks in the Ruby/Rails community. Every time I go to an event, host a workshop, give a talkโฆย I learn something new. Sometimes itโs small things like Gem::Version. Other times it completely changes my career, like the first time I heard about Hotwire Native.
Iโve taken this to heart and recently started organizing monthly Coffee and Code coworking sessions in my city, Portland, OR. Every month I post up at a local coffee shop with my laptop and invite all of the Portland Ruby Brigade to join.
This month we had five people! Itโs no corporate-sponsored-meetup but it sure is something. And the connections that folks are making during these casual events are real. Iโve already seen folks exchange emails for potential future contract gigs.
Whatโs the first step you can take today to build some community in your local area? Even if it is just finally inviting that connection-to-be for a beverageโฆ I say go for it.
If you want to join next monthโs office hours then consider becoming a paid subscriber of my newsletter. I hope to see you there! ๐
Hotwire Native Office Hours

Every month I host an hour-long Zoom session for Hotwire Native developers to ask questions, share progress, and connect with others building the same way.
Share your opinion below! Tell us your thoughts in comments!
#๏ธโฃ #Ruby #solved #problem
๐ Posted on 1762542899
