Class: RbStruct::StructBase
- Inherits:
-
Array
- Object
- Array
- RbStruct::StructBase
- Defined in:
- lib/rbstruct/rbstruct.rb
Class Attribute Summary collapse
-
.bsize ⇒ Object
readonly
Returns the value of attribute bsize.
-
.fields ⇒ Object
readonly
Returns the value of attribute fields.
-
.format_string ⇒ Object
readonly
Returns the value of attribute format_string.
-
.size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
Class Attribute Details
.bsize ⇒ Object (readonly)
Returns the value of attribute bsize.
17 18 19 |
# File 'lib/rbstruct/rbstruct.rb', line 17 def bsize @bsize end |
.fields ⇒ Object (readonly)
Returns the value of attribute fields.
17 18 19 |
# File 'lib/rbstruct/rbstruct.rb', line 17 def fields @fields end |
.format_string ⇒ Object (readonly)
Returns the value of attribute format_string.
17 18 19 |
# File 'lib/rbstruct/rbstruct.rb', line 17 def format_string @format_string end |
.size ⇒ Object (readonly)
Returns the value of attribute size.
17 18 19 |
# File 'lib/rbstruct/rbstruct.rb', line 17 def size @size end |
Instance Method Details
#inspect(d = 0) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/rbstruct/rbstruct.rb', line 112 def inspect(d=0) self.class.to_s + " {\n" + self.class.fields.each_with_index.map {|f,n| field = self.get_field(n) "\t"*(d+1) + "#{f[:type]} #{f[:name]} = " + case field when StructBase "#{field.inspect(d+1)}" else field.inspect end }.join("\n") + "\n" + "\t"*d + "}" end |
#to_s ⇒ Object
109 110 111 |
# File 'lib/rbstruct/rbstruct.rb', line 109 def to_s pack(self.class.format_string) end |
#write ⇒ Object
128 129 |
# File 'lib/rbstruct/rbstruct.rb', line 128 def write end |