Created
October 23, 2012 11:51
-
-
Save ackintosh/3938364 to your computer and use it in GitHub Desktop.
Abstract class/method in Ruby
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
# These code may not be a ruby. | |
class AbstractKlass | |
def initialize | |
raise 'Abstract Class !!' | |
end | |
def method_a | |
raise 'Called abstract method !!' | |
end | |
def method_b | |
raise 'Called abstract method !!' | |
end | |
end | |
class SubKlass < AbstractKlass | |
def method_a | |
puts "method_a !" | |
end | |
end | |
sub_klass = SubKlass.new | |
sub_klass.method_a # method_a ! | |
sub_klass.method_b # Called abstract method !! (RuntimeError) | |
abstract_klass = AbstractKlass.new # Abstract Class !! (RuntimeError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SubKlass
needs to overloadAbstractKlass#initialize
.