StringCalculator is a simple Ruby class that has a class method add
which adds numbers provided as a string supporting custom delimiters, including commas and new lines, but raises exception when negative numbers are present.
- Addition of numbers provided as a string
- Support for different delimiters (comma, new line, custom delimiter)
- Handling of negative numbers
- Unit tests using RSpec for ensuring correctness
To use the String Calculator, follow these steps:
-
Clone the repository:
git clone [email protected]:ssaha777/string_calculator.git
-
Install dependencies:
bundle install
-
Run the specs:
bundle exec rspec
-
Execution of the calculator
require_relative 'string_calculator' result = StringCalculator.add("1,2,3") puts result