Method: CStruct::Field#initialize

Defined in:
lib/cstruct/field.rb

#initialize(tag, size, offset, sign, dimension = nil, *args) ⇒ Field

Returns a new instance of Field.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cstruct/field.rb', line 9

def initialize(tag,size,offset,sign,dimension = nil,*args)
  @tag    = tag
  @size   = size 
  @offset = offset
  @sign   = sign
  @dimension = dimension
  @byte_size = size

  if @dimension
    @byte_size = @size * dimension.inject(1){|m,i| m*=i}
    @sign = :struct_array if @sign == :struct      
  end

end