Skip to content

Instantly share code, notes, and snippets.

@rewinfrey
Created January 8, 2013 17:15
Show Gist options
  • Select an option

  • Save rewinfrey/4485739 to your computer and use it in GitHub Desktop.

Select an option

Save rewinfrey/4485739 to your computer and use it in GitHub Desktop.
SOLID example for Alfonso
# don't really need Shape class
class Shape
def initialize(options)
end
def area
end
end
class CircleShape
attr_accessor :radius
def initialize(options)
self.radius = options.fetch(:radius)
end
def area
2 * Math.pi * self.radius
end
end
class RectangleShape
attr_accessor :length, :width
def initialize(options)
self.length = options.fetch(:length)
self.width = options.fetch(:width)
end
def area
@length * @width
end
end
class TriangleShape
end
class PolygonShape
end
class ProgramEmotionInterface
attr_accessor :program, :emotion
def initialize(options)
self.program = options.fetch(:program)
self.shape = options.fetch(:emotion)
end
def some_method_justifying_the_interface
end
end
class ProgramShapeInterface
attr_accessor :program, :shape
def initialize(options)
self.program = options.fetch(:program)
self.shape = options.fetch(:shape)
end
def some_method_justifying_the_interface
end
end
class Program
attr_accessor :area_sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment