Sha256: 3f7410e5d4c6c0721d01c325ce5c1cd486fe6f2271c08cef8324d4fe80d754ab

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

require 'symath/definition'

module SyMath
  class Definition::Number < Definition
    def initialize(name)
      super(name.to_s, define_symbol: false)
    end

    def description()
      return "#{name} - natural number"
    end

    def value()
      return self.name.to_s.to_i
    end

    def is_nan?()
      return false
    end
    
    def is_finite?()
      return true
    end

    def is_positive?()
      return value() > 0
    end

    def is_number?()
      return true
    end

    def is_zero?()
      return value() == 0
    end

    def type()
      return :natural.to_t
    end
  end
end

class Integer
  def to_m()
    if self < 0
      return SyMath::Definition::Number.new(-self).neg
    else
      return SyMath::Definition::Number.new(self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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