A serializable 9P2000 data structure.
Methods
Classes and Modules
Attributes
[R] | fields |
Class Public methods
Provides a convenient DSL (for defining fields) to all objects which include this module.
# File lib/rumai/ixp/message.rb, line 86 def self.included target class << target ## # 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. # # [args] arguments for Field.new() # def field name, format = nil, *args klass = Field.factory(format) field = klass.new(name.to_sym, format, *args) # register field as being part of this structure fields << field # provide accessor methods to field values self.class_eval "def \#{field.name}\n@values[\#{field.name.inspect}]\nend\n\ndef \#{field.name}= value\n@values[\#{field.name.inspect}] = value\nend\n", __FILE__, __LINE__ field end ## # Creates a new instance of this class from the # given 9P2000 byte stream and returns the instance. # def from_9p stream, msg_class = self msg = msg_class.new msg.load_9p(stream) msg end end end
Allows field values to be initialized via the constructor.
- field_values
- a mapping from field name to field value
Instance Public methods
Populates this object with information from the given 9P2000 byte stream.