Fun With Ruby
Message from 2022
This post is pretty old! Opinions and technical information in it are almost certainly oudated. Commands and configurations will probably not work. Consider the age of the content before putting any of it into practice.
I was messing around with a project this week in Ruby, and right as I was trying to figure out how to best implement extensibility and modularity, this article came along.
Main module require’d from main.rb:
class Statement @@statementtypes = Array.new #implements plug-in nature of statements def self.inherited(stmttype) @@statementtypes << stmttype end end Dir["statements/*.rb"].each do |x| load x end
And each .rb file in statements/ has a class that inherits from Statement.
No details yet on what the project is, aside from that it’s fun and challenging.