Last active
May 11, 2019 20:18
-
-
Save brandonbloom/6644f19ab6b87c4b1d487c8db0efc3b8 to your computer and use it in GitHub Desktop.
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 Rectangle | |
include Model | |
attr_accessor :left, :right, :top, :bottom, :width | |
def computed_width | |
return unless left and right | |
right - left | |
end | |
def effective_width | |
width || computed_width | |
end | |
# ... etc ... | |
def effective | |
Rectangle.new( | |
left: effective_left, | |
right: effective_right, | |
width: effective_width, | |
# ... etc | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment