After further discussions with rue: and drbrain: in ruby-lang, it turns out that my impulse to save memory by placing utility functions at the class level was inappropriate.
In Ruby, instance methods still hang from the class, and the answer should go ahead and put the utility functions at the instance level as private.
In general, a utility function that is accessed only by instance methods:
class Foo def what "it is '#{zoop}'" end private def zoop "zoop" end end p Foo.new.what # => "it is 'zoop'"
For the utility function to be called from the instance and class methods, the nested module was apparently popular:
class Foo module Util def self.zoop "zoop" end end def what "it is '#{Util.zoop}'" end class << self def class_what "for all time it is '#{Util.zoop}'" end end end p Foo.new.what
source share