# File lib/rumai/ixp/message.rb, line 77 def self.included aTarget class << aTarget # Returns a list of fields which compose this Struct. def fields @fields ||= if superclass.respond_to? :fields superclass.fields.dup else [] end end # Defines a new field in this Struct. # aArgs:: arguments for Field.new() def field aName, aFormat = nil, *aArgs c = Field.factory(aFormat) f = c.new(aName.to_sym, aFormat, *aArgs) fields << f # register field as being part of this structure # provide accessor methods to field values self.class_eval %{ def #{f.name} @values[#{f.name.inspect}] end def #{f.name}= aValue @values[#{f.name.inspect}] = aValue end } return f end # Creates a new instance of this class from the # given 9P2000 byte stream and returns the instance. def from_9p aStream, aMsgClass = self msg = aMsgClass.new msg.load_9p(aStream) msg end end end