Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/camertron/range-hash
A hash with support for grouping keys and values.
https://github.com/camertron/range-hash
Last synced: 19 days ago
JSON representation
A hash with support for grouping keys and values.
- Host: GitHub
- URL: https://github.com/camertron/range-hash
- Owner: camertron
- Created: 2015-09-24T02:55:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-24T04:21:01.000Z (over 9 years ago)
- Last Synced: 2024-11-04T00:42:04.447Z (2 months ago)
- Language: Ruby
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.txt
Awesome Lists containing this project
README
range-hash
=================[![Build Status](https://travis-ci.org/camertron/json-write-stream.svg?branch=master)](http://travis-ci.org/camertron/json-write-stream)
A hash with support for grouping keys and values.
## Installation
`gem install range-hash`
## Usage
```ruby
require 'range-hash'
```## Examples
Setting and getting key/value pairs:
```ruby
hash = RangeHash.new
hash[4..8] = 'hello'
hash[12..20] = 'world'hash[4] # => 'hello'
hash[6] # => 'hello'
hash[14] # => 'world'
hash[20] # => 'world'
````RangeHash` supports all the `Enumerable` methods like `each` and `map`:
```ruby
hash.each do |index, value|
# yields each index (4, 5, 6, 7, 8, etc) along with
# the corresponding value
end
```## Requirements
No external requirements.
## Running Tests
`bundle exec rake` should do the trick. Alternatively you can run `bundle exec rspec`, which does the same thing.
## Authors
* Cameron C. Dutro: http://github.com/camertron