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
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