Sha256: d2b0db07217183bf1675d2ac5676d6c513f18829e684cd8960cc4c579c21ba2f
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
# CarveRange Takes two date ranges (A,B) and returns an array of date ranges in A that do not overlap with date range B, and returns B. ## Example 1 Date Range A: ######### Date Range B: ##### Carve(A,B): [##, ##, ####] ## Example 1 Why? Date Range A: ######### Date Range B: ##### Date Range A': ## Date Range A'': ## A' + A'' + B: [##, ##, ####] ## Example 2 Date Range A: ##### Date Range B: ##### Carve(A,B): [##,#####] ## Example 3 Date Range A: ##### Date Range B: ### Carve(A,B): [##,###] ## Example 4 Date Range A: ##### Date Range B: ####### Carve(A,B): [#######] ## Use Case Your tracking your activity in a calendar for a month. For days 1-30, you Went Jogging, so you create an Event that Starts At Day 1 and End At day 2. Oops! You double-check your journal and realize that Day 15-18 you said you went Jogging, but actually you Stayed Home. You can "carve" the 1 Event (that contains a Start Date and and End Date) with this gem such that you could get 3 Events. The first event is Days 1-14 (you Went Jogging those days). The second event is Days 15-18 (you Stayed Home those days). The third event is Days 19-30 (you Went Jogging those days). ## Installation Add this line to your application's Gemfile: ```ruby gem 'carve_range' ``` And then execute: $ bundle Or install it yourself as: $ gem install carve_range ## 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. ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/possibly/carve_range. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
carve_range-0.1.2 | README.md |