Skip to content

Instantly share code, notes, and snippets.

@adriculous
Created July 28, 2016 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adriculous/085ce87cbed1689ddb000a77e78995f1 to your computer and use it in GitHub Desktop.
Save adriculous/085ce87cbed1689ddb000a77e78995f1 to your computer and use it in GitHub Desktop.
Attribute Accessors
# Doing some OOP (object oriented programming) where we can create our own objects and define them. I'll be using manga information as my example.
class Manga
attr_accessor :title, :mangaka, :genre
def about_manga
return "A good #{@genre} manga that I recommend for everyone to read is #{@mangaka}'s #{@title}."
end
end
my_manga = Manga.new
my_manga.title = 'Cardcaptor Sakura'
my_manga.mangaka = 'CLAMP'
my_manga.genre = 'adventure'
puts my_manga.about_manga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment