module Tool

Provides some useful procedure for linmeric

Author

Massimiliano Dal Mas (max.codeware@gmail.com)

License

Distributed under MIT license

Public Class Methods

f() click to toggle source

*returns*: array of the supported math functions; see: Function

# File lib/linmeric/CnGal_tools.rb, line 29
def self.f
  return ["log","sin","cos","PI","tan","exp"]
end
is_exp?(str) click to toggle source

Dummy function to ckeck if a string represents an expression (may not work properly)

  • *argument*: string to be checked

  • *returns*: true if `str` represents an expression; false else.

# File lib/linmeric/CnGal_tools.rb, line 45
def self.is_exp?(str)
  (str.contain? "=+*-/^") ? (return true) : (('0123456789.'.contain_all? str) ? 
  (return true):((self.letters.contain? str) ? (return true):(return false)))
end
is_keyword?(ob) click to toggle source

Checks if a string represents a keyword

  • *argument*: object to check

  • *returns*: true if `ob` represents a keyword; false else.

# File lib/linmeric/CnGal_tools.rb, line 37
def self.is_keyword?(ob)   
  (self.keys.include? ob) ? (return true) : (return false)
end
keys() click to toggle source
  • *returns*: array of all the keywords used by linmeric

# File lib/linmeric/CnGal_tools.rb, line 14
def self.keys 
  return ["mx:","t:", "shw:","shwvar:","det:","solve:","from:","as:","f:","norm:","id_mx:","integ:"]
end
letters() click to toggle source
  • *returns*: alphabet in string format

# File lib/linmeric/CnGal_tools.rb, line 24
def self.letters
  return "abcdefghijklmnopqrstuvwxyz"
end
operators() click to toggle source
  • *returns*: array of all the operators

# File lib/linmeric/CnGal_tools.rb, line 19
def self.operators
  return ["=","-","+","*","/","^",">"]
end
print_stack(stack) click to toggle source

Prints the hash of the variables

  • *argument*: hash to be printed