data_error
A DataError class library. DataError extends TypeError, and defines Numeric,
FalseClass, TrueClass, Symbol and NilClass atomic data types. If, during
execution, code expects a data type and receives another type, DataError raises.
The class defines two public methods and one private method. There is also one
default error message constant, DEFAULT_MESSAGE
.
Installation
Add this line to your application's Gemfile:
gem 'data_error', '4.0.0'
And then execute:
$ bundle
Or install it yourself as:
$ gem install data_error -v 4.0.0
Usage
There are two public methods: initialize(message = DEFAULT_MESSAGE)
and
message()
, and one private method: message=(explanation = nil)
.
Public methods
initialize(message = DEFAULT_MESSAGE)
Initializes an error. Takes a parameter message
explaining the error. If a
message was not supplied, defaults DEFAULT_MESSAGE
. DEFAULT_MESSAGE
is "The argument was neither a Numeric, FalseClass, TrueClass, Symbol, nor NilClass object."
Returns the error instance.
message()
Gets the instance variable, message
. Returns the variable's reference. The
String
returns frozen.
Private methods
message=(explanation = nil)
Sets the instance variable, message
. Takes a String
error message argument. Raises an ArgumentError
in the case the explanation is not a String
instance.
Testing
The gem was tested with 90% code coverage. Test the remaining in an interactive console.
Contributing
After checking out the repository, run bin/setup
to install dependencies.
Then, run rake test
to run the tests. You can also run bin/console
for an
interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To
relasea new version, update the version numnber in version.rb
, and then run
bundle exec rake release
, which will create a git tag for the version, push
git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/sci3nti5t/data_error. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant conduct code.
Documentation errors
In the case there is a mistake in the documentation, private message sci3nti5t and give:
- Mistake description
- Relevant line numbers
License
The gem is available as open source under the terms of the GNU GPLv3 License.
Conduct code
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the conduct code.