I am trying to write a plug-in system in ruby and I am running into a bit of trouble with never having learned a good set of fundamentals. Anyway my plug-in system is just an experiment in working with classes. My Plugin class looks like this:
class Plugin
def info
# Set some default values when a new class is created.
name = "Test Plugin"
description = "Just a simple test plugin."
version = "1.0"
end
end
In a plugin I would require the above file and write some code like so:
require "./_plugin_base.rb"
pluginCleanup = Plugin.new
pluginCleanup.info do
name = "Cleanup"
description = "Remove the files we don't need in the public folder."
version = "1.0"
end
Now, I know this code does not work. Basically what I think I want are instance variables under the info method. I have tried using true instance variables and they do work well however I want to keep these inside the info function if that makes any sense., because when I do use attr_accessor the varibles are accessable as:
pluginCleanup.name = "New Value"
Can someone tell me how I would make the code work as described in the examples above? I just want to be able to declare a new instance and call:
pluginCleanup.info.name = "New Value"