Class: Dateseq::Generator
- Inherits:
-
Object
- Object
- Dateseq::Generator
- Defined in:
- lib/dateseq.rb
Overview
Date Sequence generator
Instance Method Summary collapse
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
- #sequence(from_date, to_date) ⇒ Object
- #sequence_str(from_date, to_date) ⇒ Object
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
8 9 10 11 |
# File 'lib/dateseq.rb', line 8 def initialize() @format = [:format] || '%Y%m%d' @sep = [:sep] || "\n" end |
Instance Method Details
#sequence(from_date, to_date) ⇒ Object
13 14 15 16 17 18 19 |
# 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) ⇒ Object
21 22 23 |
# File 'lib/dateseq.rb', line 21 def sequence_str(from_date, to_date) sequence(from_date, to_date).join(@sep) end |