Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/symath/value.rb,
lib/symath/definition/number.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object



305
306
307
308
309
310
311
# File 'lib/symath/value.rb', line 305

def *(other)
  if other.class.method_defined?(:to_m) and !other.is_a?(Integer)
    return self.to_m*other.to_m
  else
    return self.super_mul(other)
  end
end

#**(other) ⇒ Object



321
322
323
324
325
326
327
# File 'lib/symath/value.rb', line 321

def **(other)
  if other.class.method_defined?(:to_m)  and !other.is_a?(Integer)
    return self.to_m**other.to_m
  else
    return self.super_pow(other)
  end
end

#+(other) ⇒ Object



289
290
291
292
293
294
295
# File 'lib/symath/value.rb', line 289

def +(other)
  if other.class.method_defined?(:to_m) and !other.is_a?(Integer)
    return self.to_m + other.to_m
  else
    return self.super_add(other)
  end
end

#-(other) ⇒ Object



297
298
299
300
301
302
303
# File 'lib/symath/value.rb', line 297

def -(other)
  if other.class.method_defined?(:to_m) and !other.is_a?(Integer)
    return self.to_m - other.to_m
  else
    return self.super_sub(other)
  end
end

#/(other) ⇒ Object



313
314
315
316
317
318
319
# File 'lib/symath/value.rb', line 313

def /(other)
  if other.class.method_defined?(:to_m) and !other.is_a?(Integer)
    return self.to_m/other.to_m
  else
    return self.super_div(other)
  end
end

#^(other) ⇒ Object



329
330
331
332
333
334
335
# File 'lib/symath/value.rb', line 329

def ^(other)
  if other.class.method_defined?(:to_m)  and !other.is_a?(Integer)
    return self.to_m^other.to_m
  else
    return self.super_wedge(other)
  end
end

#super_addObject



282
# File 'lib/symath/value.rb', line 282

alias_method :super_add, :+

#super_divObject



285
# File 'lib/symath/value.rb', line 285

alias_method :super_div, :/

#super_mulObject



284
# File 'lib/symath/value.rb', line 284

alias_method :super_mul, :*

#super_powObject



286
# File 'lib/symath/value.rb', line 286

alias_method :super_pow, :**

#super_subObject



283
# File 'lib/symath/value.rb', line 283

alias_method :super_sub, :-

#super_wedgeObject



287
# File 'lib/symath/value.rb', line 287

alias_method :super_wedge, :^

#to_mObject



44
45
46
47
48
49
50
# File 'lib/symath/definition/number.rb', line 44

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