Class: MathViz::Constant
Overview
A simple number.
Also identifies the number as true constant, which affects nodes display style, so that opportunities for constant-folding can be idenified.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Term
Instance Method Summary collapse
- #constant? ⇒ Boolean
-
#finite? ⇒ Boolean
Forward to contained object.
-
#initialize(a) ⇒ Constant
constructor
wraps a primitive value.
-
#long ⇒ Object
Debugging method; string with both name and value.
-
#shape ⇒ Object
Graphviz node shape.
-
#to_value ⇒ Object
Forward to contained object.
-
#units ⇒ Object
Returns the units of the contained object (if any) or else it’s own.
Methods inherited from Term
#anonymous?, binop, #collapse, #color, #data, #generated?, #label, list_terms, name_terms!, #style, #to_dot, #to_i, #to_s, unop
Methods included from Measured
Methods included from Units::Class
Constructor Details
#initialize(a) ⇒ Constant
wraps a primitive value
508 509 510 511 |
# File 'lib/mathviz.rb', line 508 def initialize(a) super() @a = a end |
Instance Method Details
#constant? ⇒ Boolean
538 539 540 |
# File 'lib/mathviz.rb', line 538 def constant? true end |
#finite? ⇒ Boolean
Forward to contained object
543 544 545 |
# File 'lib/mathviz.rb', line 543 def finite? @a.respond_to?(:finite?) ? @a.finite? : true end |
#long ⇒ Object
Debugging method; string with both name and value
514 515 516 517 |
# File 'lib/mathviz.rb', line 514 def long n = @name && (@name + " = ") "(#{n}#{to_value})" end |
#shape ⇒ Object
Graphviz node shape
534 535 536 |
# File 'lib/mathviz.rb', line 534 def shape :plaintext end |
#to_value ⇒ Object
Forward to contained object
520 521 522 |
# File 'lib/mathviz.rb', line 520 def to_value @a.to_value end |
#units ⇒ Object
Returns the units of the contained object (if any) or else it’s own.
525 526 527 528 529 530 531 |
# File 'lib/mathviz.rb', line 525 def units if @a.respond_to? :units @a.units else super end end |