Sha256: 12c62feeab7ffe335f518c9c9ec76e81a297c8b122e86a86fe97d7f378f38f09

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

module Danica
  class Wrapper::Constant
    include BaseOperations
    include Common

    attr_reader :value, :latex, :gnu

    default_value :priority, 10
    default_value :valued?, true
    default_value :is_grouped?, false

    def initialize(value, latex, gnu)
      @value = value
      @latex = latex
      @gnu = gnu
    end

    def to_f
      value.to_f
    end

    def ==(other)
      return false unless other.class == self.class
      gnu == other.gnu && latex == other.latex && value == other.value
    end

    def to_tex
      latex.to_s
    end

    def to_gnu
      gnu.to_s
    end
  end

  E = Wrapper::Constant.new(Math::E, :e, 'exp(1)')
  PI = Wrapper::Constant.new(Math::PI, '\pi', :pi)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danica-2.4.1 lib/danica/wrapper/constant.rb
danica-2.4.0 lib/danica/wrapper/constant.rb
danica-2.3.1 lib/danica/wrapper/constant.rb
danica-2.3.0 lib/danica/wrapper/constant.rb