class Upcoming::Generator

Attributes

choose[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/upcoming/generators/generator.rb, line 5
def initialize(options = {})
  @choose = options.fetch(:choose, :upcoming)
end

Public Instance Methods

step(from) click to toggle source
# File lib/upcoming/generators/generator.rb, line 9
def step(from)
  date_range(from).find { |date| valid?(date) }
end

Private Instance Methods

date_range(date) click to toggle source
# File lib/upcoming/generators/generator.rb, line 15
def date_range(date)
  return date.downto(date.prev_year) if choose == :preceding
  date.upto(date.next_year)
end