lib/ffi/struct_array.rb in ffi-libfuse-0.3.4 vs lib/ffi/struct_array.rb in ffi-libfuse-0.4.0

- old
+ new

@@ -8,10 +8,11 @@ # Generate a one way converter for a fixed size array of struct # @return [DataConverter] def array(size) ArrayConverter.new(self, size) end + alias [] array # @!visibility private # Helper to handle callbacks containing fixed length array of struct class ArrayConverter include DataConverter @@ -26,10 +27,10 @@ end def from_native(ptr, _ctx) return [] if ptr.null? - Array.new(@size) { |i| @type.new(ptr + (i * @type.size)) } + Array.new(@size) { |i| @type.new(ptr + (i * @type.size)) }.freeze end def to_native(ary, _ctx) raise NotImplementedError, "#{self.class.name} Cannot convert #{ary} to pointer" end