Sha256: 35f651fc1e7ae1d57611c5b9c79e0592f3ec027919d47680db1f9d39a5d47f54

Contents?: true

Size: 412 Bytes

Versions: 3

Compression:

Stored size: 412 Bytes

Contents

# frozen_string_literal: true

module Basic101

  module BasicMath

    def self.basic_math_op(method)
      define_method(method) do |other|
        a = to_float.to_f
        b = other.to_float.to_f
        result = a.send(method, b)
        BasicFloat.new(result).simplest
      end
    end

    basic_math_op :*
    basic_math_op :/
    basic_math_op :+
    basic_math_op :-
    basic_math_op :**

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-1.0.2 lib/basic101/basic_math.rb
basic101-1.0.1 lib/basic101/basic_math.rb
basic101-1.0.0 lib/basic101/basic_math.rb