class Dateseq::Generator

Date Sequence generator

Public Class Methods

new(options) click to toggle source
# File lib/dateseq.rb, line 8
def initialize(options)
  @format = options[:format] || '%Y%m%d'
  @sep = options[:sep] || "\n"
end

Public Instance Methods

sequence(from_date, to_date) click to toggle source
# File lib/dateseq.rb, line 13
def sequence(from_date, to_date)
  from = Date.parse(from_date)
  to = Date.parse(to_date)
  from.upto(to).map do |date|
    date.strftime(@format)
  end
end
sequence_str(from_date, to_date) click to toggle source
# File lib/dateseq.rb, line 21
def sequence_str(from_date, to_date)
  sequence(from_date, to_date).join(@sep)
end