Sha256: a28ed9ba11b825978c25f67dcfc172c052cafe54c60de210db38a0351e00f516

Contents?: true

Size: 751 Bytes

Versions: 2

Compression:

Stored size: 751 Bytes

Contents

require 'symath/value'
require 'symath/definition/operator'

module SyMath
  class Definition::Bounds < Definition::Operator
    def initialize()
      super(:bounds, args: [:f, :a, :b],
            exp: :f.to_m.(:b) - :f.to_m.(:a))
    end

    def description()
      return 'bounds(ex, x, a, b) - bounds operator, (ex)[x=b] - (ex)[x=a]'
    end

    def to_s(args = nil)
      if !args
        args = @args
      end

      exp = args[0]
      a = args[2]
      b = args[3]

      return "[#{exp}](#{a},#{b})"
    end

    def to_latex(args = nil)
      if !args
        args = @args
      end

      exp = args[0].to_latex
      a = args[2].to_latex
      b = args[3].to_latex

      return "\\left[#{exp}\\right]^{#{b}}_{#{a}}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symath-0.1.1 lib/symath/definition/bounds.rb
symath-0.1.0 lib/symath/definition/bounds.rb