0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
RingBuffer provides a simple ring buffer implementation in Ruby. A ring buffer is a queue with a maximum capacity. When the capacity exceeds, the first element inserted is removed.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
>= 0
~> 12.1
~> 3.6
 Project Readme

ring_buffer

ring_buffer provides a simple ring buffer implementation in Ruby. A ring buffer is a queue with a maximum capacity. When the capacity exceeds, the first element inserted is removed.

Installation

Add this line to your application's Gemfile:

gem 'ring_buffer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ring_buffer

Usage

buffer = RingBuffer.new 2
buffer << 'first element'
buffer << 'second element'
buffer << 'third element'
p buffer
# ['second element', 'third element']

Development

After checking out the repository, run bin/setup to install dependencies. Then, run rake spec 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 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.

Without installing Ruby globally

On my work station, I prefer to use a Docker image with Ruby installed instead of installing Ruby locally. Hence, any bundle … command can be prefixed with docker-compose run ring-buffer. For instance, running the tests is done with the command docker-compose run ring-buffer bundle exec rake spec.

Acknowledgment

This gem is a generalization of the wonderful work from Nimster and its ringbuffer gist.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/EtienneM/proc_parser.

License

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