Skip to content

Instantly share code, notes, and snippets.

@artemeff
Forked from pirj/gist:6152272
Created Aug 6, 2013
Embed
What would you like to do?
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