Created
July 28, 2016 08:06
-
-
Save adriculous/085ce87cbed1689ddb000a77e78995f1 to your computer and use it in GitHub Desktop.
Attribute Accessors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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