class Friend attr_accessor :name, :age, :phone def initialize(name, age, phone) @name, @age, @phone = name, age, phone end end f1 = Friend.new("John", 30, "555-1212") f1.instance f1.instance.update({:name=>'Jerry'}) f1.instance
Alias for update
Instance evaluation.
Instance vairable names as symbols.
Instance variable names as strings.
Return instance variables with values as a hash.
class X def initialize(a,b) @a, @b = a, b end end x = X.new(1,2) x.instance.to_h #=> { :a=>1, :b=>2 }
Alias for to_h
Set instance variables given a hash.
instance.update('@a'=>1, '@b'=>2) @a #=> 1 @b #=> 2
Also, +@+ sign is not neccessary.
instance.update(:a=>1, :b=>2) @a #=> 1 @b #=> 2
Instance variable values.
Same as instance_variables.
[Validate]