Sha256: bfdef304e31878731ab47d517e446cb772ec6805c8241f979c6108522c86c2d3

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

class Adder
  def add( a, b )
    a.to_f + b.to_f
  end
end

class Subtractor
  def subtract( a, b )
    a.to_f - b.to_f
  end
end

class Multiplier
  def multiply( a, b )
    a.to_f * b.to_f
  end
end

class Divider
  def divide( a, b )
    a.to_f / b.to_f
  end
end

class Calculator
  attr_writer :adder
  attr_writer :subtractor
  attr_writer :multiplier
  attr_writer :divider

  def add( a, b )
    @adder.add( a, b )
  end

  def subtract( a, b )
    @subtractor.subtract( a, b )
  end

  def multiply( a, b )
    @multiplier.multiply( a, b )
  end

  def divide( a, b )
    @divider.divide( a, b )
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
copland-0.8.0 tutorial/02/tutorial.rb
copland-1.0.0 tutorial/02/tutorial.rb