Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract.rb

Instance Method Summary collapse

Instance Method Details

#abstract_method(args_str, *method_names) ⇒ Object

define abstract methods



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/abstract.rb', line 41

def abstract_method args_str, *method_names
  method_names.each do |name|
    module_eval "      def \#{name}(\#{args_str})\n        mesg = \"class \\\#{self.class.name} must implement abstract method `\#{self.name}#\#{name}()'.\"\n        #mesg = \"\\\#{self.class.name}#\#{name}() is not implemented.\"\n        err = NotImplementedError.new mesg\n        err.set_backtrace caller()\n        raise err\n      end\n    END\n  end\nend\n"