Class: MathViz::Operation::Unary

Inherits:
MathViz::Operation show all
Defined in:
lib/mathviz.rb

Overview

Special cases for unary operators

Instance Attribute Summary

Attributes inherited from Term

#name

Instance Method Summary collapse

Methods inherited from MathViz::Operation

#collapse, #color, #constant?, #finite?, #initialize, #link_from, #long, #shape, #units

Methods inherited from Term

#anonymous?, binop, #collapse, #color, #data, #generated?, #label, list_terms, name_terms!, #shape, #style, #to_i, #to_s, unop

Methods included from Measured

#per, #unit, #units, #with_units

Methods included from Units::Class

#included, #new_units

Constructor Details

This class inherits a constructor from MathViz::Operation

Instance Method Details

#to_dot(g) ⇒ Object

Extend Graphviz g with a representation of this object, and incoming connections



653
654
655
656
# File 'lib/mathviz.rb', line 653

def to_dot(g)
  super
  @operands.each {|x| link_from(g, x, :normal, true)}
end

#to_valueObject

Apply the operator to create the derived value.



647
648
649
650
# File 'lib/mathviz.rb', line 647

def to_value
  return MathViz::Infinity unless finite?
  @operands.map(&:to_value).map(&@op).first
end