Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
Created June 28, 2016 07:47
Show Gist options
  • Save stevenocchipinti/9abb260b24a93896c740730b62243073 to your computer and use it in GitHub Desktop.
Save stevenocchipinti/9abb260b24a93896c740730b62243073 to your computer and use it in GitHub Desktop.
A simple demonstration of classes in Ruby
#
# person.rb
#
# This is a simple Person class
# It really doesn't do much, but it demonstrates the use of classes in Ruby
#
class Person
attr_accessor :name
def initialize(name)
@name = name
end
def say(text)
puts "#{name} says: '#{text}'"
end
end
@bob = Person.new("Bob")
@bob.say "Hello world"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment