README.md in multi_range-0.0.1 vs README.md in multi_range-0.0.2
- old
+ new
@@ -6,16 +6,13 @@
[![Code Climate](https://codeclimate.com/github/khiav223577/multi_range/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/multi_range)
[![Test Coverage](https://codeclimate.com/github/khiav223577/multi_range/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/multi_range/coverage)
## Supports
- Ruby 1.8 ~ 2.7
-- Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0
## Installation
-Provides cross-rails methods for you to upgrade rails, backport features, create easy-to-maintain gems, and so on.
-
```ruby
gem 'multi_range'
```
And then execute:
@@ -25,9 +22,53 @@
Or install it yourself as:
$ gem install multi_range
## Usage
+
+Allow you to manipulate a group of ranges.
+
+### Sample a number
+```rb
+multi_range = MultiRange.new([1..5, 10..12])
+multi_range.sample
+# => equals to [1, 2, 3, 4, 5, 10, 11, 12].sample
+```
+
+### Range difference
+```rb
+multi_range = MultiRange.new([1..10])
+multi_range -= 5..7
+multi_range.ranges
+# => [1...5, 8..10]
+```
+
+```rb
+multi_range = MultiRange.new([1..10, 50..70, 80..100])
+multi_range -= 5..85
+multi_range.ranges
+# => [1...5, 86..100]
+```
+
+### Range-like interface
+
+#### each
+```rb
+MultiRange([1..3, 5..6]).each{|s| print s }
+# => 12356
+```
+
+#### map
+```rb
+MultiRange([1..3, 5..6]).map{|s| s * 2 }
+# => [2, 4, 6, 10, 12]
+```
+
+#### index_with
+```rb
+MultiRange([1..3, 5..6]).index_with(true)
+# => { 1 => true, 2 => true, 3 => true, 5 => true, 6 => true }
+```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.