Sha256: 36e99600e06c92429935cf3e7e1c93043518cf14a4a419b4099f41a1c441f502

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

module Plurimath
  module Math
    module Function
      class UnaryFunction
        attr_accessor :parameter_one

        def initialize(parameter_one = nil)
          @parameter_one = parameter_one
        end

        def ==(object)
          object.class == self.class &&
            object.parameter_one == parameter_one
        end

        def to_asciimath
          "#{class_name}#{value_to_asciimath}"
        end

        def value_to_asciimath
          "(#{parameter_one.to_asciimath})" unless parameter_one.nil?
        end

        def to_mathml_without_math_tag
          "<mi>#{class_name}</mi>"
        end

        def to_latex
          first_value = "{#{parameter_one.to_latex}}" if parameter_one
          "\\#{class_name}#{first_value}"
        end

        def class_name
          self.class.name.split("::").last.downcase
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plurimath-0.2.0 lib/plurimath/math/function/unary_function.rb