Created
August 4, 2013 22:47
-
-
Save pirj/6152272 to your computer and use it in GitHub Desktop.
Template module
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 BaseWall | |
def self.Wall length, width, material | |
Module.new do | |
define_method(:length) { length } | |
define_method(:width) { width } | |
define_method(:material) { material } | |
def self.included clazz | |
private :length, :width, :material | |
end | |
end | |
end | |
def dimensions | |
"I am #{length}ft. long and #{width}ft. wide!" | |
end | |
def made_from | |
"I am made from #{material}!" | |
end | |
end | |
class BrickWall < BaseWall | |
include Wall(30, 20, 'brick') | |
end | |
class ConcreteWall < BaseWall | |
include Wall(30, 20, 'concrete') | |
end | |
class WoodWall < BaseWall | |
include Wall(10, 20, 'wood') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment