README.md in repeatable-0.5.0 vs README.md in repeatable-0.6.0
- old
+ new
@@ -20,10 +20,14 @@
Or install it yourself as:
$ gem install repeatable
+## Requirements
+
+Because this gem relies heavily on required keyword arguments, especially to make dumping and parsing of schedules simpler, this code will only work on **Ruby 2.1** and higher.
+
## Usage
### Building a Schedule
You can create a schedule in one of two ways.
@@ -31,13 +35,13 @@
#### Composed objects
Instantiate and compose each of the `Repeatable::Expression` objects manually.
```ruby
-second_monday = Repeatabe::Expression::WeekdayInMonth.new(weekday: 1, count: 2)
+second_monday = Repeatable::Expression::WeekdayInMonth.new(weekday: 1, count: 2)
oct_thru_dec = Repeatable::Expression::RangeInYear.new(start_month: 10, end_month: 12)
-intersection = Repeatable::Expresson::Intersection.new(second_monday, oct_thru_dec)
+intersection = Repeatable::Expression::Intersection.new(second_monday, oct_thru_dec)
schedule = Repeatable::Schedule.new(intersection)
```
@@ -47,11 +51,12 @@
```ruby
arg = {
intersection: [
{ weekday_in_month: { weekday: 1, count: 2 } },
- { range_in_year: { start_month: 10, end_month: 12 } }
+ { range_in_year: { start_month: 10, end_month: 12 } },
+ { exact_date: { date: "2015-08-01" } }
]
}
schedule = Repeatable::Schedule.new(arg)
```
@@ -71,29 +76,41 @@
# All conditions must be met
{ intersection: [] }
Repeatable::Expression::Intersection.new(expressions)
+# Date is part of the first set (`included`) but not part of the second set (`excluded`)
+{ difference: { included: expression, excluded: another_expression } }
+Repeatable::Expression::Difference.new(included: expression, excluded: another_expression)
+
# DATES
# Every Sunday
{ weekday: { weekday: 0 } }
Repeatable::Expression::Weekday.new(weekday: 0)
# The 3rd Monday of every month
{ weekday_in_month: { weekday: 1, count: 3 } }
Repeatable::Expression::WeekdayInMonth.new(weekday: 1, count: 3)
+# The last Thursday of every month
+{ weekday_in_month: { weekday: 4, count: -1 } }
+Repeatable::Expression::WeekdayInMonth.new(weekday: 4, count: -1)
+
# Every other Monday, starting from December 1, 2015
{ biweekly: { weekday: 1, start_date: '2015-12-01' } }
Repeatable::Expression::Biweekly.new(weekday: 1, start_date: Date.new(2015, 12, 1))
# The 13th of every month
{ day_in_month: { day: 13 } }
Repeatable::Expression::DayInMonth.new(day: 13)
+# The last day of every month
+{ day_in_month: { day: :last } }
+Repeatable::Expression::DayInMonth.new(day: :last)
+
# All days in October
{ range_in_year: { start_month: 10 } }
Repeatable::Expression::RangeInYear.new(start_month: 10)
# All days from October through December
@@ -101,9 +118,13 @@
Repeatable::Expression::RangeInYear.new(start_month: 10, end_month: 12)
# All days from October 1 through December 20
{ range_in_year: { start_month: 10, end_month: 12, start_day: 1, end_day: 20 } }
Repeatable::Expression::RangeInYear.new(start_month: 10, end_month: 12, start_day: 1, end_day: 20)
+
+# only December 21, 2012
+{ exact_date: { date: '2012-12-21' } }
+Repeatable::Expression::ExactDate.new(date: Date.new(2012, 12, 21)
```
#### Schedule Errors
If something in the argument passed into `Repeatable::Schedule.new` can't be handled by the `Schedule` or `Parser` (e.g. an expression hash key that doesn't match an existing expression class), a `Repeatable::ParseError` will be raised with a (hopefully) helpful error message.