Module: Tool
- Defined in:
- lib/linmeric/CnGal_tools.rb
Overview
Provides some useful procedure for linmeric
- Author
-
Massimiliano Dal Mas ([email protected])
- License
-
Distributed under MIT license
Class Method Summary collapse
-
.f ⇒ Object
returns: array of the supported math functions; see: Function.
-
.is_exp?(str) ⇒ Boolean
Dummy function to ckeck if a string represents an expression (may not work properly).
-
.is_keyword?(ob) ⇒ Boolean
Checks if a string represents a keyword.
-
.keys ⇒ Object
-
returns: array of all the keywords used by linmeric.
-
-
.letters ⇒ Object
-
returns: alphabet in string format.
-
-
.operators ⇒ Object
-
returns: array of all the operators.
-
-
.print_stack(stack) ⇒ Object
Prints the hash of the variables.
Class Method Details
.f ⇒ Object
returns: array of the supported math functions; see: Function
29 30 31 |
# File 'lib/linmeric/CnGal_tools.rb', line 29 def self.f return ["log","sin","cos","PI","tan","exp"] end |
.is_exp?(str) ⇒ Boolean
Dummy function to ckeck if a string represents an expression (may not work properly)
-
argument: string to be checked
-
returns:
trueif ‘str` represents an expression;falseelse.
45 46 47 48 |
# 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) ⇒ Boolean
Checks if a string represents a keyword
-
argument: object to check
-
returns:
trueif ‘ob` represents a keyword;falseelse.
37 38 39 |
# File 'lib/linmeric/CnGal_tools.rb', line 37 def self.is_keyword?(ob) (self.keys.include? ob) ? (return true) : (return false) end |
.keys ⇒ Object
-
returns: array of all the keywords used by linmeric
14 15 16 |
# 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 ⇒ Object
-
returns: alphabet in string format
24 25 26 |
# File 'lib/linmeric/CnGal_tools.rb', line 24 def self.letters return "abcdefghijklmnopqrstuvwxyz" end |
.operators ⇒ Object
-
returns: array of all the operators
19 20 21 |
# File 'lib/linmeric/CnGal_tools.rb', line 19 def self.operators return ["=","-","+","*","/","^",">"] end |
.print_stack(stack) ⇒ Object
Prints the hash of the variables
-
argument: hash to be printed
53 54 55 56 57 58 59 |
# File 'lib/linmeric/CnGal_tools.rb', line 53 def self.print_stack(stack) stack.keys.each do |k| puts "#{k} = " if stack[k].is_a? Matrix print "#{k} = " unless stack[k].is_a? Matrix puts stack[k] end end |