Module: CAS::Help

Defined in:
lib/Mr.CAS.rb

Overview

Support functions are in this separate Helper class

Class Method Summary collapse

Class Method Details

.assert(obj, type) ⇒ Object

Check input ‘obj.class` against a `type` class raises an `ArgumentError` if check fails

* **argument**: object to be cecked
* **argument**: type to be checked against
* **returns**: `TrueClass`, or raises an `ArgumentError`

Raises:

  • (ArgumentError)


58
59
60
61
# File 'lib/Mr.CAS.rb', line 58

def self.assert(obj, type)
  raise ArgumentError, "required #{type}, received #{obj.class}" unless obj.is_a? type
  return true
end

.assert_name(obj) ⇒ Object

Check if input object is feasible to be a name of a ‘CAS::Variable` or a `CAS::Function` raise an `ArgumentError` if the check fails. To be feasible the object must be a `String` instance or `Symbol` instance

* **argument**: object to be checked
* **returns**: `TrueClass` or raises `ArgumentError`

Raises:

  • (ArgumentError)


69
70
71
72
# File 'lib/Mr.CAS.rb', line 69

def self.assert_name(obj)
  raise ArgumentError, "Input name must be a String/Symbol" unless [Symbol, String].include? obj.class
  return true
end