newnewmembers==[ ][ ]=eachlengthmemberssizeto_avalues
Subclasses: Struct::Tms
A Struct is a convenient way to bundle a number of attributes
together, using accessor methods, without having to write an explicit
class.
The Struct class is a generator of specific classes, each one of
which is defined to hold a set of variables and their accessors. In
these examples, we'll call the generated class ``CustomerClass,'' and
we'll show an example instance of that class as ``CustomerInst.''
In the descriptions that follow, the
parameter aSymbol refers to a symbol, which is either a
quoted string or a Symbol (such as :name).
Creates a new class, named by aString, containing
accessor methods for the given symbols.
If the name aString is omitted, an anonymous structure
class will be created. Otherwise, the name of this struct will
appear as a constant in class Struct, so it must be unique
for all Structs in the system and should start with a
capital letter.
Struct.new returns a new Class object, which can then be used
to create specific instances of the new structure.
The remaining methods listed below (class and instance) are
defined for this generated class. See the description that follows
for an example.
Creates a new instance. The number of actual parameters must be
less than or equal to the number of attributes defined for this
class; unset parameters default to nil. Passing too many
parameters will raise an ArgumentError.
Equality---Returns true if anOtherStruct is equal to this
one: they must be of the same class as generated by
Struct.new, and the values of
all instance variables must be equal (according to
Object#==).
Attribute Reference---Returns the value of the instance variable
named by aSymbol, or indexed (0..length-1) by
anInteger. Will raise NameError if the named
variable does not exist, or IndexError if the index is out of range.
Attribute Assignment---Assigns to the instance variable named by
aSymbol or anInteger
the value anObject and returns it. Will raise
a NameError if the named variable does not exist, or an
IndexError if the index is out of range.