Changeset 204

Show
Ignore:
Timestamp:
06/07/05 05:06:13 (3 years ago)
Author:
ged
Message:

- Added an ::abstract code-gen function for virtual methods.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/simplest-thing/lib/fm/gameobject.rb

    r198 r204  
    135135        else 
    136136            return 0 
     137        end 
     138    end 
     139 
     140 
     141    ### Define a method that will raise a NotImplementedError when 
     142    ### called. This enforces implementation of a particular interface in 
     143    ### subclasses of the defining class. 
     144    def self::abstract( *syms ) 
     145        syms.each do |meth| 
     146            define_method( meth ) { 
     147                raise NotImplementedError, 
     148                "No implementation for \#%s provided by %s" % 
     149                [ meth, self.class.name ] 
     150            } 
    137151        end 
    138152    end