Sha256: e6d8efd4f6e359dbe4b49d9e76d72bb912b2ab04647b140042795af83cb1fd3e
Contents?: true
Size: 450 Bytes
Versions: 30
Compression:
Stored size: 450 Bytes
Contents
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
Version data entries
30 entries across 29 versions & 7 rubygems