Fun With Ruby
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.