Class: RbStruct::StructBase

Inherits:
Array
  • Object
show all
Defined in:
lib/rbstruct/rbstruct.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.bsizeObject (readonly)

Returns the value of attribute bsize.



17
18
19
# File 'lib/rbstruct/rbstruct.rb', line 17

def bsize
  @bsize
end

.fieldsObject (readonly)

Returns the value of attribute fields.



17
18
19
# File 'lib/rbstruct/rbstruct.rb', line 17

def fields
  @fields
end

.format_stringObject (readonly)

Returns the value of attribute format_string.



17
18
19
# File 'lib/rbstruct/rbstruct.rb', line 17

def format_string
  @format_string
end

.sizeObject (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_sObject



109
110
111
# File 'lib/rbstruct/rbstruct.rb', line 109

def to_s
  pack(self.class.format_string)
end

#writeObject



128
129
# File 'lib/rbstruct/rbstruct.rb', line 128

def write
end