David A. Black wrote:
> For the initialize thing, I would probably do something like this:
> 
>    class Whatever
>      DEFAULTS = {
>                   :select_max => 10000,
>                   :select_try => 1000,
>                   :min_sleep_sec => 5,
>                   :max_sleep_sec => 1800,
>                   :default_sleep => 10
>                 }
> 
>      def initialize(opts)
>        DEFAULTS.update(opts).each do |name, value|
>          instance_variable_set("@#{name}", value)
>        end
>      end
>    end

Note: if you want subclasses to be able override the DEFAULTS, then use 
self.class::DEFAULTS instead of just DEFAULTS. Otherwise DEFAULTS will 
statically resolve to Whatever::DEFAULTS.

You might also want to add DEFAULTS.freeze, to prevent you accidentally 
mucking them up (as 'update' does :-)
-- 
Posted via http://www.ruby-forum.com/.