/usr/lib/ruby/1.8/extlib/struct.rb is in libextlib-ruby1.8 0.9.13-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 | class Struct
##
# Get a hash with names and values of all instance variables.
#
# class Foo < Struct.new(:name, :age, :gender); end
# f = Foo.new("Jill", 50, :female)
# f.attributes #=> {:name => "Jill", :age => 50, :gender => :female}
#
# @return [Hash] Hash of instance variables in receiver, keyed by ivar name
#
# @api public
def attributes
h = {}
each_pair { |k,v| h[k] = v }
h
end
end # class Struct
|