README

Path: README
Last Update: Tue Jun 09 22:07:58 +0100 2009

Position Range Gem documentation

  "Ranges with attributes that can be juggled"

Allows you to assign random attributes to ranges and juggle them in lists. Also adds parsing from string, but most intereting when used in a PositionRange::List.

There standard set operations can be applied to it, like additions, substractions and intersections. In addition you can also get the combined size of all the ranges in the list. And cluster overlapping ranges, maintaining the attributes (more below).

PositionRange is a library by the LogiLogi Foundation, extracted from www.logilogi.org (foundation.logilogi.org).

Usage

First require it.

  $ irb

  > require 'rubygems'
  > require 'positionrange'

You can assign random attributes to PositionRanges.

  > r = PositionRange.new(1,10, :cow => 'moo')
  => 1...10
  > r.cow
  => "moo"

You can also create a PositionRange::List directly from a string.

  > l = PositionRange::List.from_s('0,10:5,15')
  => [0...10, 5...15]

Then you can get the combined size.

  > l.range_size
  => 20

Or line up overlaps.

  > l.line_up_overlaps!.to_s
  => "0,5:5,10:5,10:10,15"

Clustering overlaps maintains attributes.

  > l = PositionRange::List.new([
              PositionRange.new(0,10, :cow => 'moo'),
              PositionRange.new(5,15, :goat => 7)
            ])
  => [0...10, 5...15]

  > output = [
        PositionRange::List.new([
            PositionRange.new(0,5, :cow => 'moo')]),
        PositionRange::List.new([
            PositionRange.new(5,10, :cow => 'moo'),
            PositionRange.new(5,10, :goat => 7)]),
        PositionRange::List.new([
            PositionRange.new(10,15, :goat => 7)])
      ]
  => [[0...5], [5...10, 5...10], [10...15]]

  > l.cluster_overlaps == output
  => true

Installation

You can install PositionRange with the following command:

  % [sudo] gem install positionrange

The latest version of Diff LCS can also be downloaded at:

And then from its distribution directory installed with:

  % [sudo] ruby install.rb

Support

The PositionRange homepage is positionrange.rubyforge.org.

For the latest news on PositionRange:

Feel free to submit commits or feature requests. If you send a patch, remember to update the corresponding unit tests.

This Documentation

This documentation can be browsed online at:

Copyrights

PositionRange and these docs are Copyright (c) 2006-2009 The LogiLogi Foundation. PositionRange is licensed under the GNU Lesser General Public License. These docs are available under the Creative Commons Attribution-Share Alike License.

You can use PositionRange in an application that is not Free Software but PositionRange itself remains Free Software.

[Validate]