Ruby: Define a class
A short, tested Ruby example for define a class. Copy it and adjust the names and paths for your project.
Ruby
class Dog
attr_reader :name
def initialize(name)
@name = name
end
def bark
"#{name} says woof"
end
endFind it in Zest
Search for “ruby define a class” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.