https://newsletter.masilotti.com/p/ruby-already-solved-my-problem Hotwire Native Weekly Hotwire Native Weekly SubscribeSign in Ruby already solved my problem One great question in office hours led me to delete a whole class. Joe Masilotti's avatar Joe Masilotti Nov 07, 2025 4 1 2 Share Yesterday I hosted November's Hotwire Native Office Hours. Hotwire Native Office Hours Hotwire Native Office Hours Joe Masilotti * Sep 17 Read full story 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 "#{major}.#{minor}.#{patch}" 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! The power of community, no matter how small 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 Joe Masilotti * Sep 17 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. Read full story 4 1 2 Share Discussion about this post CommentsRestacks User's avatar [ ] [ ] [ ] [ ] Bendangelo's avatar Bendangelo 19h Where can we watch the talks? Expand full comment Reply Share TopLatestDiscussions No posts Ready for more? [ ] Subscribe (c) 2025 Joe Masilotti Privacy [?] Terms [?] Collection notice Start your SubstackGet the app Substack is the home for great culture This site requires JavaScript to run correctly. Please turn on JavaScript or unblock scripts