Sha256: ad04d1a83de7bad5675a88e4e709143fccb45543f04d676d95ab2ae5b0eea583

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

module Mathmas
  # Internal use only
  # Instantiated by Symbol#coerce or Expression#coerce
  #
  # @example
  #   5*(x + y)
  #
  # x + y is calcurated first and an instance of Expression is created.
  # Then Fixnum#* has no rule when its argument is an instance of Expression so Expression#coerce is called.
  # At last Expression#coerce calls Number#new.
  #
  # Multiply(Number(5), Plus(Symbol(x), Symbol(y))
  #
  class Number
    include Mathmas::Basic
    attr_accessor :num

    def initialize(num)
      @num = num
    end

    def to_s
      @num.to_s
    end

    def to_tex
      @num.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mathmas-0.0.1 lib/mathmas/core/number.rb