Sha256: 25b379df7be4a593fcd42c9ef2fe07d8b214a7c370c5dcfcbfe23cdd24c62814

Contents?: true

Size: 474 Bytes

Versions: 2

Compression:

Stored size: 474 Bytes

Contents

module Danica
  module DSL
    def self.register(method, clazz=nil)
      define_method method do |*args|
        clazz = "Danica::#{method.to_s.camelize}".constantize unless clazz
        clazz.new(*args)
      end
    end

    def function(*variables, &block)
      Function.build(*variables, &block).new
    end
  end

  %i(
    sum product division sin cos power number
    squared_root exponential group negative
  ).each do |method|
    DSL.register(method)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.2.1 lib/danica/dsl.rb
danica-2.2.0 lib/danica/dsl.rb