class Rstruct::ArrayType
Attributes
count[R]
Public Class Methods
new(name, typ, count, opts={}, &block)
click to toggle source
Calls superclass method
# File lib/rstruct/base_types/array_type.rb, line 13 def initialize(name, typ, count, opts={}, &block) opts = opts.dup lkupreg = (opts.delete(:fields_from) || opts.delete(:register) || Rstruct.default_registry) super(name, opts.merge(:register => false), &block) @count = count unless @rtype = lkupreg[typ] raise(InvalidTypeError, "invalid array type #{typ.inspect}") end end
Public Instance Methods
fields()
click to toggle source
# File lib/rstruct/base_types/array_type.rb, line 27 def fields @fields ||= Array.new(self.count){|i| Field.new(i, @rtype, nil, nil) }.freeze end
instance(*values)
click to toggle source
# File lib/rstruct/base_types/array_type.rb, line 31 def instance(*values) vals = values.flatten ary = ArrayContainer.new(self.count){|f| vals.shift } ary.rstruct_type = self return ary end
offset_of(idx)
click to toggle source
# File lib/rstruct/base_types/array_type.rb, line 38 def offset_of(idx) rtype.sizeof * idx end
typ()
click to toggle source
# File lib/rstruct/base_types/array_type.rb, line 23 def typ self end