Class: ActiveWarehouse::Builder::DateGenerator
- Inherits:
-
AbstractGenerator
- Object
- AbstractGenerator
- ActiveWarehouse::Builder::DateGenerator
- Defined in:
- lib/active_warehouse/builder/random_data_builder.rb
Overview
Basic Date generator
Direct Known Subclasses
Instance Method Summary collapse
-
#generate(column, options = {}) ⇒ Object
Generate a random date value.
Instance Method Details
#generate(column, options = {}) ⇒ Object
Generate a random date value
Options:
-
:start_date
: The start date as a Date or Time object (default 1 year ago) -
:end_date
: The end date as a Date or Time object (default now)
127 128 129 130 131 132 |
# File 'lib/active_warehouse/builder/random_data_builder.rb', line 127 def generate(column, ={}) end_date = ([:end_date] || Time.now).to_date start_date = ([:start_date] || 1.year.ago).to_date number_of_days = end_date - start_date start_date + rand(number_of_days) end |