Created
October 30, 2009 20:49
-
-
Save knzai/222710 to your computer and use it in GitHub Desktop.
An example of differing ways of abstracting initialization into the parent
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
class AbstractScraper | |
def initialize(username, password) | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = "Windows Mozilla" | |
@agent.keep_alive = false | |
login(username, password) | |
end | |
end | |
class NormalAScraper < AbstractScraper | |
end | |
class NormalBScraper < AbstractScraper | |
end | |
class GoofyScraper < AbstractScraper | |
def initialize | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = "Windows Mozilla" | |
@agent.keep_alive = false | |
login | |
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
class AbstractScraper | |
def initialize(username, password) | |
initialize_agent | |
login(username, password) | |
end | |
def initialize_agent | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = "Windows Mozilla" | |
@agent.keep_alive = false | |
end | |
end | |
class NormalAScraper < AbstractScraper | |
end | |
class NormalBScraper < AbstractScraper | |
end | |
class GoofyScraper < AbstractScraper | |
def initialize | |
initialize_agent | |
login | |
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
class AbstractScraper | |
def initialize_agent | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = "Windows Mozilla" | |
@agent.keep_alive = false | |
end | |
end | |
class NormalAScraper < AbstractScraper | |
def initialize(username, password) | |
initialize_agent | |
login(username, password) | |
end | |
end | |
class NormalBScraper < AbstractScraper | |
def initialize(username, password) | |
initialize_agent | |
login(username, password) | |
end | |
end | |
class GoofyScraper < AbstractScraper | |
def initialize | |
initialize_agent | |
login | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment