0.0
No commit activity in last 3 years
No release in over 3 years
With this gem you are able to sum array of strings values. Primary ment for summing array of hours in format ["20:25","10:10"].strings_to_sum(':') which will result as "30:35" hours/minutes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.16
~> 10.0
 Project Readme

SumStrings

Simple gem which allows you to sum array of strings values. Primary ment for summing array of hours in format ["20:25","10:10"].strings_to_sum(':'). Which will result in a string 30:35.

Code solution used by sample provided on stackoverflow by Cary Swoveland, thanks.

Installation

Add this line to your application's Gemfile:

gem 'sum_strings'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sum_strings

Usage

Sample for summing array of string values like hours. We have array with some hours which we need to sum. Sample array: working_hours = ["09:20","5:10","08:00","23:20","10:13"]

Summing this array we can do like: working_hours.sum_strings(':')

The gem is extended method of ruby Array calss so calling method sum_strings(':') with providing split char as parameter.

Result would be: 56:3

In case that you have some other split char you just need to provide it to a method. Sample: working_hours = ["09-20","5-10","08-00","23-20","10-13"] sum_strings('-')

Here is a simple project where you can see practical usage of the gem https://github.com/nezirz/use_sum_strings

This is how the summing looks: alt text

Development

After checking out the repo, run bin/setup to install dependencies. 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 release a new version, update the version number 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/nezirz/sum_strings. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the SumStrings project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.