Sha256: 9b47fe74b9e6f948e6ab8d7a786d0c6e73e9abe0f59523229eb317a97c93011c

Contents?: true

Size: 639 Bytes

Versions: 14

Compression:

Stored size: 639 Bytes

Contents

module Danica
  class Operator::Functional < Operator
    variables :value
    default_value :is_grouped?, true

    def self.build(operator:, text: nil, tex: nil, gnu: nil)
      text = "#{operator}(:value:)" if text.nil?
      tex = text if tex.nil?
      gnu = text if gnu.nil?

      Class.new(self) do
        module_eval(%Q(
          def to_f
            Math.#{operator}(value.to_f)
          end

          def to_tex
            '#{tex.gsub(':value:', "' + value.to_tex + '")}'
          end

          def to_gnu
            '#{gnu.gsub(':value:', "' + value.to_gnu + '")}'
          end
        ))
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
danica-2.6.4 lib/danica/operator/functional.rb
danica-2.6.3 lib/danica/operator/functional.rb
danica-2.6.2 lib/danica/operator/functional.rb
danica-2.6.1 lib/danica/operator/functional.rb
danica-2.6.0 lib/danica/operator/functional.rb
danica-2.5.1 lib/danica/operator/functional.rb
danica-2.5.0 lib/danica/operator/functional.rb
danica-2.4.4 lib/danica/operator/functional.rb
danica-2.4.3 lib/danica/operator/functional.rb
danica-2.4.2 lib/danica/operator/functional.rb
danica-2.4.1 lib/danica/operator/functional.rb
danica-2.4.0 lib/danica/operator/functional.rb
danica-2.3.1 lib/danica/operator/functional.rb
danica-2.3.0 lib/danica/operator/functional.rb