Changeset 197

Show
Ignore:
Timestamp:
11/20/04 14:42:52 (4 years ago)
Author:
ged
Message:

-- Moved over gameobject tests from trunk.
-- Added enough versioning stuff to get gameobject tests.

Location:
branches/simplest-thing
Files:
1 added
1 modified

Legend:

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

    r188 r197  
    128128 
    129129 
     130    ### Versioning method -- return the subversion rev number for the object. 
     131    def self::rev 
     132        revno = self::const_get( :SVNRev ) 
     133        if revno.match( /(\d+)/ ) 
     134            return Integer($1) 
     135        else 
     136            return 0 
     137        end 
     138    end 
     139 
     140 
    130141    ############################################################# 
    131142    ### I N S T A N C E   M E T H O D S 
     
    136147        super() 
    137148 
     149        # Add unique ID and rev 
    138150        @id = self.class::makeObjectId( self ) 
     151        @rev = self.class::rev 
     152 
     153        # Call setters for named arguments 
    139154        args.each {|method, value| 
    140155            self.send( "#{method}=", value ) 
     
    147162        super 
    148163        @id = self.class::makeObjectId( self ) 
    149         self.log.debug "Cloned #{self.class.name} #{original.muesid}." 
     164        self.log.debug "Cloned #{self.class.name} #{original.id}." 
    150165    end 
    151166 
     
    157172    # The object's unique id 
    158173    attr_reader :id 
     174 
     175    # The revision number of the class from which the object was instantiated at 
     176    # the time of its creation or last upgrade. 
     177    attr_reader :rev 
    159178 
    160179 
     
    174193 
    175194        rval << self.htmlObjectHeader( inline ) 
    176         rval << self.htmlIvarSection( inline, "@muesid" ) 
     195        rval << self.htmlIvarSection( inline, "@id" ) 
    177196        rval << self.htmlObjectFooter( inline ) 
    178197 
     
    187206    ### Return an HTML fragment for the header part of the given object. 
    188207    def htmlObjectHeader( inline ) 
    189         func = inline ? HTML::method(:span) : HTML::method(:div) 
     208        func = inline ? 
     209            FaerieMUD::HTML::method(:span) : 
     210            FaerieMUD::HTML::method(:div) 
    190211 
    191212        # The outer object header 
    192213        return func.call( :class => "object-header" ) { 
    193214            [ 
    194                 HTML::span( :class => "object-class" ) { 
     215                FaerieMUD::HTML::span( :class => "object-class" ) { 
    195216                    self.class.name 
    196217                }, 
    197                 HTML::span( :class => "object-id" ) { 
    198                     "#%s" % self.muesid 
     218                FaerieMUD::HTML::span( :class => "object-id" ) { 
     219                    "#%s" % self.id 
    199220                }, 
    200                 HTML::span( :class => "object-class-version" ) { 
    201                     "(v%s)" % self.class.version.to_s 
     221                FaerieMUD::HTML::span( :class => "object-class-version" ) { 
     222                    "(v%d)" % self.class.rev 
    202223                }, 
    203224            ].join(" ") 
     
    208229    ### Return an HTML fragment for the footer part of the given object. 
    209230    def htmlObjectFooter( inline ) 
    210         func = inline ? HTML::method(:span) : HTML::method(:div) 
     231        func = inline ? 
     232            FaerieMUD::HTML::method(:span) : 
     233            FaerieMUD::HTML::method(:div) 
    211234 
    212235        return func.call( :class => "object-footer" ) { 
    213             HTML::span( :class => "object-contrib" ) { 
     236            FaerieMUD::HTML::span( :class => "object-contrib" ) { 
    214237                "Authors: " + 
    215238                self.class.authors.collect {|author,points| 
    216                     HTML::span( :class => "object-contrib-author" ) {author.to_s} + 
     239                    FaerieMUD::HTML::span( 
     240                        :class => "object-contrib-author" ) {author.to_s} + 
    217241                    ": " + 
    218                     HTML::span( :class => "object-contrib-points" ) {points.to_s} 
     242                    FaerieMUD::HTML::span( 
     243                        :class => "object-contrib-points" ) {points.to_s} 
    219244                }.join("; ") 
    220245            } 
     
    238263            # Fetch the instance variable and turn it into HTML 
    239264            value = instance_variable_get( var ) 
    240             html = HTML::convertObject( value, inline ) 
     265            html = FaerieMUD::HTML::convertObject( value, inline ) 
    241266            classes = [] 
    242267 
     
    247272            end 
    248273 
    249             rval << HTML::ivarElement( var, html, inline, *classes ) 
     274            rval << FaerieMUD::HTML::ivarElement( var, html, inline, *classes ) 
    250275        } 
    251276 
     
    259284    ### container will be a <div> element for block display. 
    260285    def htmlWrapper( content, inline=false ) 
    261         func = inline ? HTML::method(:span) : HTML::method(:div) 
     286        func = inline ? 
     287            FaerieMUD::HTML::method(:span) : 
     288            FaerieMUD::HTML::method(:div) 
    262289 
    263290        classes = [ 
     
    266293        ].join(" ") 
    267294        return func.call( 
    268             :id => "oid-" + self.muesid, 
     295            :id => "oid-" + self.id, 
    269296            :class => classes ) { 
    270297            "\n" + content + "\n"