Class: Upcoming::Factory
- Inherits:
-
Object
- Object
- Upcoming::Factory
- Includes:
- Enumerable
- Defined in:
- lib/upcoming/factory.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(options = {}) ⇒ Factory
constructor
A new instance of Factory.
- #then_find_preceding(method) ⇒ Object
- #then_find_upcoming(method) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Factory
Returns a new instance of Factory.
8 9 10 11 |
# File 'lib/upcoming/factory.rb', line 8 def initialize( = {}) @options = parse() @chain = [] end |
Class Method Details
.every(method, options = {}) ⇒ Object
13 14 15 |
# File 'lib/upcoming/factory.rb', line 13 def self.every(method, = {}) new().then_find_upcoming(method) end |
Instance Method Details
#each ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/upcoming/factory.rb', line 27 def each from = @options[:from] while true do from += 1 next_date = @chain.first.step(from) yield @chain[1..-1].inject(next_date) { |date, generator| generator.step(date) } from = next_date end end |
#then_find_preceding(method) ⇒ Object
22 23 24 25 |
# File 'lib/upcoming/factory.rb', line 22 def then_find_preceding(method) @chain << create_generator(method, :preceding) self end |
#then_find_upcoming(method) ⇒ Object
17 18 19 20 |
# File 'lib/upcoming/factory.rb', line 17 def then_find_upcoming(method) @chain << create_generator(method, :upcoming) self end |