-
-
Save tjsingleton/941767 to your computer and use it in GitHub Desktop.
A nonsensical example of what I want to do. Someone please fill in the blanks.
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
module Parser | |
@formats = {} | |
class << self | |
attr_accessor :formats | |
def create(format) | |
formats[format].new | |
end | |
end | |
class Base | |
def self.inherited(subclass) | |
format = subclass.to_s.split('::').last.downcase.to_sym | |
Parser.formats[format] = subclass | |
end | |
end | |
end | |
class Parser::Html < Parser::Base | |
end | |
class Parser::Pdf < Parser::Base | |
end | |
parser = Parser.create(type: :html) | |
parser.class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yeah, that's helpful.