Class: Rumai::IXP::Struct::Field
Overview
A field inside a Struct.
A field’s value is considered to be either:
- array of format when counter && format.is_a? Class
- raw byte string when counter && format.nil?
Direct Known Subclasses
Defined Under Namespace
Modules: CounteeField, CounterField
Instance Attribute Summary
-
- (Object) countee
Returns the value of attribute countee.
-
- (Object) counter
Returns the value of attribute counter.
-
- (Object) format
readonly
Returns the value of attribute format.
-
- (Object) name
readonly
Returns the value of attribute name.
Class Method Summary
-
+ (Object) factory(format)
Returns a Field class that best represents the given format.
Instance Method Summary
-
- (Field) initialize(name, format = nil, counter = nil)
constructor
A new instance of Field.
-
- (Object) load_9p(stream, field_values)
Populates this object with information taken from the given 9P2000 byte stream.
-
- (Object) to_9p(field_values)
Transforms this object into a string of 9P2000 bytes.
Constructor Details
- (Field) initialize(name, format = nil, counter = nil)
A new instance of Field
153 154 155 156 157 158 |
# File 'lib/rumai/ixp/message.rb', line 153 def initialize name, format = nil, counter = nil @name = name @format = format @countee = nil self.counter = counter end |
Instance Attribute Details
- (Object) countee
Returns the value of attribute countee
141 142 143 |
# File 'lib/rumai/ixp/message.rb', line 141 def countee @countee end |
- (Object) counter
Returns the value of attribute counter
141 142 143 |
# File 'lib/rumai/ixp/message.rb', line 141 def counter @counter end |
- (Object) format (readonly)
Returns the value of attribute format
141 142 143 |
# File 'lib/rumai/ixp/message.rb', line 141 def format @format end |
- (Object) name (readonly)
Returns the value of attribute name
141 142 143 |
# File 'lib/rumai/ixp/message.rb', line 141 def name @name end |
Class Method Details
+ (Object) factory(format)
Returns a Field class that best represents the given format.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/rumai/ixp/message.rb', line 184 def self.factory format if format == String StringField elsif format.is_a? Class ClassField elsif format == 8 Integer8Field else Field end end |
Instance Method Details
- (Object) load_9p(stream, field_values)
Populates this object with information taken from the given 9P2000 byte stream.
210 211 212 |
# File 'lib/rumai/ixp/message.rb', line 210 def load_9p stream, field_values field_values[@name] = value_from_9p stream end |
- (Object) to_9p(field_values)
Transforms this object into a string of 9P2000 bytes.
202 203 204 |
# File 'lib/rumai/ixp/message.rb', line 202 def to_9p field_values value_to_9p field_values[@name] end |