Skip to content

Instantly share code, notes, and snippets.

@TalkativeTree
Created April 20, 2013 22:40
Show Gist options
  • Save TalkativeTree/5427703 to your computer and use it in GitHub Desktop.
Save TalkativeTree/5427703 to your computer and use it in GitHub Desktop.
Review of someone else's code
class Rectangle
attr_accessor :width, :height
def initialize(width, height)
@width = width
@height = height
end
def ==(other)
(other.width == self.width && other.height == self.height ) ||
(other.height == self.width && other.width == self.height )
end
end
def rectangle_area(ar)
area = []
ar.each do
area << self.(width * height)
end
area
end
def rectangle_perimeter(pm)
perim = []
pm.each do
perim << self.((width * 2) + (height * 2))
end
perim
end
def rectangle_diagonal(dg)
diag = []
dg.each.to_f do
diag << self.(Math.sqrt(@width**2 + @height**2))
end
diag
end
def rectangle_square(sq)
squr = []
sq.each do
if width == height
return true
else
return false
end
squr
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment