Class: EquationValue
Overview
Implements basic numeric values as the Equation class
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Equation
#*, #**, #+, #-, #/, #__simplify__, #coerce, #derivative, #eval, #inspect, #simplify, #to_s
Constructor Details
Returns a new instance of EquationValue.
226
227
228
|
# File 'lib/symcalc.rb', line 226
def initialize(value)
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
224
225
226
|
# File 'lib/symcalc.rb', line 224
def value
@value
end
|
Instance Method Details
#==(value) ⇒ Object
242
243
244
245
246
247
248
|
# File 'lib/symcalc.rb', line 242
def ==(value)
if value.is_a? EquationValue
return @value == value.value
else
return false
end
end
|
#__derivative__(variable: nil) ⇒ Object
238
239
240
|
# File 'lib/symcalc.rb', line 238
def __derivative__ variable: nil
return EquationValue.new 0
end
|
#__eval__(var_hash) ⇒ Object
234
235
236
|
# File 'lib/symcalc.rb', line 234
def __eval__ var_hash
return @value.to_f
end
|
#__get_m_elements__(var_hash) ⇒ Object
259
260
261
262
263
264
265
266
|
# File 'lib/symcalc.rb', line 259
def __get_m_elements__ var_hash
if var_hash.keys.include? self
var_hash[self] = var_hash[self] + 1
else
var_hash[self] = 1
end
return var_hash
end
|
#all_variables ⇒ Object
269
270
271
|
# File 'lib/symcalc.rb', line 269
def all_variables
[]
end
|
#display ⇒ Object
230
231
232
|
# File 'lib/symcalc.rb', line 230
def display
return @value.to_s
end
|
#eql?(obj) ⇒ Boolean
254
255
256
257
|
# File 'lib/symcalc.rb', line 254
def eql? obj
return false if !obj.is_a? EquationValue
return obj.value == @value
end
|
#hash ⇒ Object
250
251
252
|
# File 'lib/symcalc.rb', line 250
def hash
1111000 + @value
end
|