Created
April 3, 2009 18:26
-
-
Save knowtheory/89878 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/ruby | |
| #creating a new class: | |
| class Anime | |
| def initialize(title, year, genre) | |
| @title=title | |
| @year=year | |
| @genre=genre | |
| end | |
| def to_s | |
| "Some more famous are: #@title #@year #@genre" | |
| end | |
| end | |
| #subclass of 'Anime': | |
| class Newtitles<Anime #meaning from 2009; | |
| def initialize(title, year, genre, based_on) | |
| @based_on = based_on | |
| super(title,year,genre) | |
| end | |
| def to_s | |
| super + "[#@based_on]" | |
| end | |
| end |
This file contains hidden or 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
| >> newtitle = Newtitles.new("Ghost in the Shell: Stand Alone Complex", 2005, "Cyberpunk", "Ghost In the Shell") | |
| => #<Newtitles:0x51a7e8 @genre="Cyberpunk", @based_on="Ghost In the Shell", @year=2005, @title="Ghost in the Shell: Stand Alone Complex"> | |
| >> newtitle.to_s | |
| => "Some more famous are: Ghost in the Shell: Stand Alone Complex 2005 Cyberpunk[Ghost In the Shell]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment