class Calcula::Expr

All valid tree expression must be childrens of this class and should be placed under the module `Calcula::Exprs`

@see Calcula::Exprs @abstract @author Paul T.

Public Instance Methods

children() click to toggle source

Returns the child nodes as a list. Child nodes must be transversible (hence also expressions).

@return [Array<Calcula::Expr>] A list of transversible child nodes

# File lib/Expr.rb, line 37
def children
  []
end
to_s(form: :src) click to toggle source

Converts the expression to a string. If the form is `:src`, then the resulting string should resemble as much as its source code as possible. If the form is `:tree`, the result string should resemble in a Lisp like form. If the form is `:ruby`, the result should be Ruby code that does the same thing. Otherwise, `nil` should be returned.

@param form [Optional, Symbol] The type of format being converted into @return [String, nil] A string that resembles the specify form

# File lib/Expr.rb, line 20
def to_s(form: :src)
  case form
  when :src then
    ""
  when :tree then
    "()"
  when :ruby then
    ""
  else
    nil
  end
end