Sha256: be34fb736125a0d4cba89382241688d684832fa3d20ee845cf31ba2a457c98d3

Contents?: true

Size: 547 Bytes

Versions: 9

Compression:

Stored size: 547 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
danica-2.7.4 lib/danica/equation/builder.rb
danica-2.7.3 lib/danica/equation/builder.rb
danica-2.7.2 lib/danica/equation/builder.rb
danica-2.7.1 lib/danica/equation/builder.rb
danica-2.6.4 lib/danica/equation/builder.rb
danica-2.6.3 lib/danica/equation/builder.rb
danica-2.6.2 lib/danica/equation/builder.rb
danica-2.6.1 lib/danica/equation/builder.rb
danica-2.6.0 lib/danica/equation/builder.rb