Class: Fixnum
- Inherits:
-
Object
- Object
- Fixnum
- Defined in:
- lib/overloading/fixnum.rb
Overview
Overloading operators for Fixnum. Operations that are oveloaded are:
-
‘overloaded_plus` for `+`
-
‘overloaded_minus` for `-`
-
‘overloaded_mul` for `*`
-
‘overloaded_div` for `/`
-
‘overloaded_pow` for `**`
Instance Method Summary collapse
-
#*(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation.
-
#**(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation.
-
#+(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation.
-
#-(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation.
-
#/(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation.
- #overloaded_div ⇒ Object
- #overloaded_minus ⇒ Object
- #overloaded_mul ⇒ Object
-
#overloaded_plus ⇒ Object
Setting aliases.
- #overloaded_pow ⇒ Object
Instance Method Details
#*(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation
41 42 43 44 |
# File 'lib/overloading/fixnum.rb', line 41 def *(a) return (CAS::const(self) * a) if a.is_a? CAS::Op self.overloaded_mul a end |
#**(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation
57 58 59 60 |
# File 'lib/overloading/fixnum.rb', line 57 def **(a) return (CAS::const(self) ** a) if a.is_a? CAS::Op self.overloaded_pow a end |
#+(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation. If
25 26 27 28 |
# File 'lib/overloading/fixnum.rb', line 25 def +(a) return (CAS::const(self) + a) if a.is_a? CAS::Op self.overloaded_plus a end |
#-(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation
33 34 35 36 |
# File 'lib/overloading/fixnum.rb', line 33 def -(a) return (CAS::const(self) - a) if a.is_a? CAS::Op self.overloaded_minus a end |
#/(a) ⇒ Object
If ‘a` is a `CAS::Op` transform self in a `CAS::Const` and return a symbolic operation
49 50 51 52 |
# File 'lib/overloading/fixnum.rb', line 49 def /(a) return (CAS::const(self) / a) if a.is_a? CAS::Op self.overloaded_div a end |
#overloaded_div ⇒ Object
17 |
# File 'lib/overloading/fixnum.rb', line 17 alias :overloaded_div :/ |
#overloaded_minus ⇒ Object
15 |
# File 'lib/overloading/fixnum.rb', line 15 alias :overloaded_minus :- |
#overloaded_mul ⇒ Object
16 |
# File 'lib/overloading/fixnum.rb', line 16 alias :overloaded_mul :* |
#overloaded_plus ⇒ Object
Setting aliases
14 |
# File 'lib/overloading/fixnum.rb', line 14 alias :overloaded_plus :+ |
#overloaded_pow ⇒ Object
18 |
# File 'lib/overloading/fixnum.rb', line 18 alias :overloaded_pow :** |