Sha256: 1dee6d033c4fa2b80a6b6cdecf91015766ae08c44dee7f457f84dd54af55a478

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# RangeBuilder

[![Build History][2]][1]

[1]: http://travis-ci.org/tracksun/range_builder
[2]: https://secure.travis-ci.org/tracksun/range_builder.png?branch=master

Builds ranges from an enumeration

## Installation

Add this line to your application's Gemfile:

    gem 'range_builder'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install range_builder

## Usage


    persons = [15, 60, 15, 61, 59, 19].map{|age| Person.new(age: age) }

    RangeBuilder.build_range( persons ){|person| person.age }

    # returns range from mininal to maximal data:
    # ( <Person aged 15> .. <Person aged 61> )
   

    sorted_array = [ 2, 3, 4, 6, 7, 9, 11, 12, 13]
 
    # sorted_array must be sorted and elements must implement successor: #succ
 
    RangeBuilder.build_from_sorted(sorted_array)
 
    # returns array of ranges:
    # [ (2..4), (6..7), (9..9), (11..13) ]

   

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
range_builder-1.0.2 README.md