Skip to content

Commit

Permalink
Replace Temp with Query.
Browse files Browse the repository at this point in the history
  • Loading branch information
josemotanet committed May 29, 2013
1 parent 087f3c9 commit b1d949e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions replace-temp-with-query/lib/after.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Cuboid
attr_reader :length, :width, :height
def initialize length, width, height
@length = length
@width = width
@height = height
end

def volume
area * height
end

def area
length * width
end
end
13 changes: 13 additions & 0 deletions replace-temp-with-query/lib/before.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Cuboid
attr_reader :length, :width, :height
def initialize length, width, height
@length = length
@width = width
@height = height
end

def volume
area = length * width
area * height
end
end
6 changes: 6 additions & 0 deletions replace-temp-with-query/test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@

require 'before' if ENV["BEFORE"]
require 'after' unless ENV["BEFORE"]

describe Cuboid do
it "has a volume" do
Cuboid.new(2,3,4).volume.must_equal 24
end
end

0 comments on commit b1d949e

Please sign in to comment.