{"id":18605338,"url":"https://github.com/fny/ranger","last_synced_at":"2025-08-24T09:37:14.996Z","repository":{"id":33401302,"uuid":"37046460","full_name":"fny/ranger","owner":"fny","description":null,"archived":false,"fork":false,"pushed_at":"2015-06-08T05:10:38.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-16T19:47:41.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-08T04:49:46.000Z","updated_at":"2015-06-08T05:00:24.000Z","dependencies_parsed_at":"2022-08-25T19:21:08.564Z","dependency_job_id":null,"html_url":"https://github.com/fny/ranger","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fny/ranger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Franger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Franger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Franger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Franger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fny","download_url":"https://codeload.github.com/fny/ranger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Franger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271836889,"owners_count":24831305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T02:20:57.869Z","updated_at":"2025-08-24T09:37:14.952Z","avatar_url":"https://github.com/fny.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DANGER ZONE :construction:\n\n***Note this gem is a work in progress and probably will have its git history rewritten prior to it's v0.1.0 release*** Fork and use at your own peril.\n\n# Ranger :water_buffalo:\n\nWrangle together numeric ranges and set your boundary conditions.\n\n## Usage\n\n### `Ranger::Interval`\n\nThink `Range` with defined endpoint conditions.\n\n```ruby\nrequire 'ranger/interval'\n\ninterval = Ranger::Interval(:open, 1, 2 :closed) # =\u003e Intv(1, 2]\n\ninterval.cover?(1)   # =\u003e false\ninterval.cover?(1.5) # =\u003e true\ninterval.cover?(2)   # =\u003e true\n\ninterval.left_open? # =\u003e true\ninterval.left_closed? # =\u003e false\n\nshorthand = Ranger::Interval(:o, 1, 2, :c)\ninterval == shorthand # =\u003e true\n\n```\n\n### `Ranger::Map`\n\n#### Instantiation\n\nNote interval/range-value pairs for all maps ***MUST*** have no overlaps and must be listed with left-endpoints in increasing order. See the section below entitled \"Validity\" for details.\n\n```ruby  \nrequire 'ranger/map'\n\nmap = Ranger::Map.new(\n  1...2 =\u003e :a,\n  2...3 =\u003e :b,\n  3...Float::INFINITY =\u003e :c\n)\n\nmap[1] # =\u003e :a\nmap[1.1] # =\u003e :a\nmap[2] # =\u003e :b\nmap[2.1] # =\u003e :b\nmap[3] # =\u003e :c\nmap[3.1] # =\u003e :c\nmap[Float::INFINITY] # =\u003e nil\n\nRanger::Map.new(\n  [:closed, 1, 2, :open ] =\u003e :a,\n  [:c, 2, 3, :o] =\u003e :b\n)\n```\n\nIf you've required `ranger/interval` you define your maps with `Ranger::Interval`. This is required for any intervals that have an open left-endpoint.\n\n```ruby\nrequire 'ranger/interval'\nrequire 'ranger/map'\n\nmap = Ranger::Map.new(\n  [:open, 1, 2, :closed] =\u003e :a,\n  [:o, 3, 5, :o] =\u003e :b,\n  Ranger::Interval(:c, 7, 9, :c) =\u003e :c\n)\n\n\n```\n\n#### Shorthand Instantiation\n\nMost times, you'll use the same boundary conditions across all the intervals in your map. Ranger provides an abbreviated notation for the closed-to-open or open-to-closed cases:\n\n##### Closed-to-open Shorthand\n\n```ruby\nrequire 'ranger/map'\n\nRanger::Map.closed_to_open(\n  1 =\u003e :a,\n  2 =\u003e :b,\n  3 =\u003e nil  # Required, otherwise [2, 3) will be dropped\n)\n\n#        -∞     1  2  3     ∞\n# (-∞, 1) o-...-o              # =\u003e nil, since nothing matches\n# [1, 2)        x--o           # =\u003e :a\n# [2, 3)           x--o        # =\u003e :b\n# [3, ∞)              x-...-o  # =\u003e nil, since nothing matches\n```\n\n##### Open-to-closed Shorthand\n\n```ruby\nrequire 'ranger/interval' # Open-to-closed requires Ranger::Interval\nrequire 'ranger/map'\n\nRanger::Map.new_open_to_closed(\n  1 =\u003e nil, # Required, otherwise (1, 2] will be dropped\n  2 =\u003e :a,\n  3 =\u003e :b\n)\n\n#        -∞     1  2  3     ∞\n# (-∞, 1] o-...-o              # =\u003e nil, since nothing matches\n# (1, 2]        o--x           # =\u003e :a\n# (2, 3]           o--x        # =\u003e :b\n# (3, ∞)              x-...-o  # =\u003e nil, since nothing matches\n\n```\n\n\n#### Validity\n\n**WARNING: Invalid maps _will_ misbehave.** Interval/range-value pairs provided to a map **MUST** follow these rules to be considered `#valid?` and function properly:\n\n  - There must be no overlaps between the two intervals\n  - The left-most endpoint of the intervals must be in increasing order\n\n```ruby\nrequire 'ranger/map'\n\nvalid_map = Map.new(\n  1...4 =\u003e :a,\n  4..6 =\u003e :b\n)\nvalid_map.valid? # =\u003e true\n\n\ninvalid_map = Map.new(\n  1..4 =\u003e :a,\n  4..6 =\u003e :b\n)\ninvalid_map.valid? # =\u003e false\n\nother_invalid_map = Map.new(\n  4...6 =\u003e :b,\n  1..4 =\u003e :a,\n)\nother_invalid_map.valid? # =\u003e false\n```\n\n### `Ranger::Table`\n\n```ruby\nrequire 'ranger/table'\n```\n\nDocs coming soon.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'ranger'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ranger\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\n1. Fork it (https://github.com/[my-github-username]/ranger/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffny%2Franger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffny%2Franger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffny%2Franger/lists"}