ruby initialize class code example
Example 1: ruby create object with attributes
class MyObject
attr_accessor :attribute1, :attribute2, :attribute3
end
test_object = MyObject.new
test_object.attribute1 = "Holy cow!"
Example 2: class ruby
Classes in Ruby are first-class objects—each is an instance of class Class . When a new class is created, an object of type Class is initialized and assigned to a global constant ( Name in this case). Classes, modules, and objects are interrelated.