Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Last active May 11, 2019 20:18
Show Gist options
  • Save brandonbloom/6644f19ab6b87c4b1d487c8db0efc3b8 to your computer and use it in GitHub Desktop.
Save brandonbloom/6644f19ab6b87c4b1d487c8db0efc3b8 to your computer and use it in GitHub Desktop.
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