Objectives
Resources
Creating the Computer Object
computer_object.rb
...Object
using Object.new
. to_s
method!computer = Object.new
# @brand
# @name
# @model
# @os
def computer.set_brand(brand)
@brand = brand
end
def computer.get_brand
@brand
end
def computer.set_name(name)
@name = name
end
def computer.get_name
@name
end
#to_s is string representation of what is in our object
def computer.to_s
return @name.to_s + " is a computer made by " + @brand.to_s
end
computer.set_name("Macbook")
computer.set_brand("Apple")
computer.to_s