Class: MathViz::Operation

Inherits:
Term show all
Defined in:
lib/mathviz.rb

Overview

Base class for MathViz::Operation::Binary and MathViz::Operation::Unary

Direct Known Subclasses

Binary, Unary

Defined Under Namespace

Classes: Binary, Unary

Instance Attribute Summary

Attributes inherited from Term

#name

Instance Method Summary collapse

Methods inherited from Term

binop, #data, #label, list_terms, name_terms!, #style, #to_dot, #to_i, #to_s, unop

Methods included from Measured

#per, #unit, #units, #with_units

Methods included from Units::Class

#included, #new_units

Instance Method Details

#colorObject

Default Graphviz node color.



492
493
494
# File 'lib/mathviz.rb', line 492

def color
  :red
end

#shapeObject

Graphviz node shape



487
488
489
# File 'lib/mathviz.rb', line 487

def shape
  :box
end

#term(x) ⇒ Object

Turn the object into a MathViz::Term (MathViz::Constant) if isn’t already a MathViz::Term. This allows for operator parameters to be primitive values without needing MathViz#const, MathViz#input, or units.



478
479
480
481
482
483
484
# File 'lib/mathviz.rb', line 478

def term(x)
  if (x.kind_of?(MathViz::Term))
    x
  else
    MathViz::Constant.new(x)
  end
end