Class: Symbolic::Constant
- Inherits:
-
Object
- Object
- Symbolic::Constant
- Includes:
- Symbolic
- Defined in:
- lib/symbolic/constant.rb
Constant Summary
Constants included from Symbolic
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #diff(wrt) ⇒ Object
-
#initialize(value, name = nil) ⇒ Constant
constructor
Create a new Symbolic::Variable, with optional name, value and proc.
- #subs(to_replace, replacement = nil) ⇒ Object
-
#variables ⇒ Object
yeah, it’s not a variable, but it acts like one as far as value is concerned.
Methods included from Symbolic
#*, #**, #+, #+@, #-, #-@, #/, #coerce, #factorial, #inspect, #operations, #taylor, #to_s
Constructor Details
#initialize(value, name = nil) ⇒ Constant
Create a new Symbolic::Variable, with optional name, value and proc
7 8 9 10 |
# File 'lib/symbolic/constant.rb', line 7 def initialize(value , name = nil) @name, @value = name, value @name = @name.to_s if @name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/symbolic/constant.rb', line 4 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/symbolic/constant.rb', line 4 def value @value end |
Instance Method Details
#diff(wrt) ⇒ Object
19 20 21 |
# File 'lib/symbolic/constant.rb', line 19 def diff(wrt) 0 end |
#subs(to_replace, replacement = nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/symbolic/constant.rb', line 11 def subs(to_replace, replacement=nil) if replacement == nil and to_replace.is_a?(Hash) super(to_replace) else return replacement if self == to_replace self end end |
#variables ⇒ Object
yeah, it’s not a variable, but it acts like one as far as value is concerned
23 24 25 |
# File 'lib/symbolic/constant.rb', line 23 def variables [self] end |