Instantiation code example

For this example, we will have an Invoice class. Inside the class definition, we have attributes, such as a customer and total, along with some behavior, such as printing out an invoice summary:

class Invoice
attr_accessor:customer, :total

def summary
puts "Invoice:"
puts "Customer: #{customer}"
puts "Total: #{total}"
end
end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.165.247