Sha256: 968bcaea116f9e86b04bdcbac0884f479f686c0d4b791b86116eac246b42c13c

Contents?: true

Size: 578 Bytes

Versions: 3

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

module Danica
  class Equation::Builder
    attr_reader :variables

    def initialize(*variables, &block)
      @variables = variables
      instance_eval(&block)
    end

    def build
      vars = variables
      l = left
      r = right

      Class.new(Equation) do
        variables(*vars)

        define_method :left, l
        define_method :right, r
      end
    end

    def left(&block)
      @left = block if block_given?
      @left
    end

    def right(&block)
      @right = block if block_given?
      @right
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.7.7 lib/danica/equation/builder.rb
danica-2.7.6 lib/danica/equation/builder.rb
danica-2.7.5 lib/danica/equation/builder.rb