Module: CAS::Help
- Defined in:
- lib/Mr.CAS.rb
Overview
Support functions are in this separate Helper class
Class Method Summary collapse
-
.assert(obj, type) ⇒ Object
Check input ‘obj.class` against a `type` class raises an `ArgumentError` if check fails.
-
.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.
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`
35 36 37 38 |
# File 'lib/Mr.CAS.rb', line 35 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`
46 47 48 49 |
# File 'lib/Mr.CAS.rb', line 46 def self.assert_name(obj) raise ArgumentError, "Input name must be a String/Symbol" unless [Symbol, String].include? obj.class return true end |