Class: Mathmas::Number
- Inherits:
-
Object
- Object
- Mathmas::Number
- Includes:
- Basic
- Defined in:
- lib/mathmas/core/number.rb
Overview
Internal use only Instantiated by Symbol#coerce or Expression#coerce
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))
Instance Attribute Summary collapse
-
#num ⇒ Object
Returns the value of attribute num.
Instance Method Summary collapse
-
#initialize(num) ⇒ Number
constructor
A new instance of Number.
- #to_s ⇒ Object
- #to_tex ⇒ Object
Methods included from Basic
#*, #**, #+, #-, #/, #coerce, #to_iruby
Constructor Details
#initialize(num) ⇒ Number
Returns a new instance of Number.
18 19 20 |
# File 'lib/mathmas/core/number.rb', line 18 def initialize(num) @num = num end |
Instance Attribute Details
#num ⇒ Object
Returns the value of attribute num.
16 17 18 |
# File 'lib/mathmas/core/number.rb', line 16 def num @num end |
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/mathmas/core/number.rb', line 22 def to_s @num.to_s end |
#to_tex ⇒ Object
26 27 28 |
# File 'lib/mathmas/core/number.rb', line 26 def to_tex @num.to_s end |