/usr/share/doc/ruby-cstruct/examples/array_member.rb is in ruby-cstruct 1.0.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # CStruct Examples
require 'cstruct'
# example:
# struct T in C\C++ (32-bit platform):
#
# struct T
# {
# int element[8];
# };
# struct T in Ruby:
class T < CStruct
int32:elements,[8]
end
# create a T's instance
t_array = T.new
(0..7).each do |i|
t_array.elements[i] = i # assign like as C language
end
# output
(0..7).each {|i| puts "t_array.elements[#{i}] = #{t_array.elements[i]}" }
# Actually,t_array.elements.class is Array. So..
t_array.elements.each {|element| puts element }
|