Changeset 197
- Timestamp:
- 11/20/04 14:42:52 (4 years ago)
- Location:
- branches/simplest-thing
- Files:
-
- 1 added
- 1 modified
-
lib/fm/gameobject.rb (modified) (11 diffs)
-
tests/gameobject.tests.rb (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/simplest-thing/lib/fm/gameobject.rb
r188 r197 128 128 129 129 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 130 141 ############################################################# 131 142 ### I N S T A N C E M E T H O D S … … 136 147 super() 137 148 149 # Add unique ID and rev 138 150 @id = self.class::makeObjectId( self ) 151 @rev = self.class::rev 152 153 # Call setters for named arguments 139 154 args.each {|method, value| 140 155 self.send( "#{method}=", value ) … … 147 162 super 148 163 @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}." 150 165 end 151 166 … … 157 172 # The object's unique id 158 173 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 159 178 160 179 … … 174 193 175 194 rval << self.htmlObjectHeader( inline ) 176 rval << self.htmlIvarSection( inline, "@ muesid" )195 rval << self.htmlIvarSection( inline, "@id" ) 177 196 rval << self.htmlObjectFooter( inline ) 178 197 … … 187 206 ### Return an HTML fragment for the header part of the given object. 188 207 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) 190 211 191 212 # The outer object header 192 213 return func.call( :class => "object-header" ) { 193 214 [ 194 HTML::span( :class => "object-class" ) {215 FaerieMUD::HTML::span( :class => "object-class" ) { 195 216 self.class.name 196 217 }, 197 HTML::span( :class => "object-id" ) {198 "#%s" % self. muesid218 FaerieMUD::HTML::span( :class => "object-id" ) { 219 "#%s" % self.id 199 220 }, 200 HTML::span( :class => "object-class-version" ) {201 "(v% s)" % self.class.version.to_s221 FaerieMUD::HTML::span( :class => "object-class-version" ) { 222 "(v%d)" % self.class.rev 202 223 }, 203 224 ].join(" ") … … 208 229 ### Return an HTML fragment for the footer part of the given object. 209 230 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) 211 234 212 235 return func.call( :class => "object-footer" ) { 213 HTML::span( :class => "object-contrib" ) {236 FaerieMUD::HTML::span( :class => "object-contrib" ) { 214 237 "Authors: " + 215 238 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} + 217 241 ": " + 218 HTML::span( :class => "object-contrib-points" ) {points.to_s} 242 FaerieMUD::HTML::span( 243 :class => "object-contrib-points" ) {points.to_s} 219 244 }.join("; ") 220 245 } … … 238 263 # Fetch the instance variable and turn it into HTML 239 264 value = instance_variable_get( var ) 240 html = HTML::convertObject( value, inline )265 html = FaerieMUD::HTML::convertObject( value, inline ) 241 266 classes = [] 242 267 … … 247 272 end 248 273 249 rval << HTML::ivarElement( var, html, inline, *classes )274 rval << FaerieMUD::HTML::ivarElement( var, html, inline, *classes ) 250 275 } 251 276 … … 259 284 ### container will be a <div> element for block display. 260 285 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) 262 289 263 290 classes = [ … … 266 293 ].join(" ") 267 294 return func.call( 268 :id => "oid-" + self. muesid,295 :id => "oid-" + self.id, 269 296 :class => classes ) { 270 297 "\n" + content + "\n"
