Class: ETL::Builder::TimeDimensionBuilder
- Defined in:
- lib/etl/builder/time_dimension_builder.rb
Overview
Builder that creates a simple time dimension.
Instance Method Summary collapse
-
#build(options = {}) ⇒ Object
Returns an array of hashes representing records in the dimension.
-
#initialize ⇒ TimeDimensionBuilder
constructor
A new instance of TimeDimensionBuilder.
Constructor Details
#initialize ⇒ TimeDimensionBuilder
Returns a new instance of TimeDimensionBuilder.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/etl/builder/time_dimension_builder.rb', line 5 def initialize # Returns an array of hashes representing records in the dimension. The values for each record are # accessed by name. def build(={}) records = [] 0.upto(23) do |t_hour| 0.upto(59) do |t_minute| 0.upto(59) do |t_second| t_hour_string = t_hour.to_s.rjust(2, '0') t_minute_string = t_minute.to_s.rjust(2, '0') t_second_string = t_second.to_s.rjust(2, '0') record = {} record[:hour] = t_hour record[:minute] = t_minute record[:second] = t_second record[:minute_description] = "#{t_hour_string}:#{t_minute_string}" record[:full_description] = "#{t_hour_string}:#{t_minute_string}:#{t_second_string}" records << record end end end records end end |
Instance Method Details
#build(options = {}) ⇒ Object
Returns an array of hashes representing records in the dimension. The values for each record are accessed by name.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/etl/builder/time_dimension_builder.rb', line 8 def build(={}) records = [] 0.upto(23) do |t_hour| 0.upto(59) do |t_minute| 0.upto(59) do |t_second| t_hour_string = t_hour.to_s.rjust(2, '0') t_minute_string = t_minute.to_s.rjust(2, '0') t_second_string = t_second.to_s.rjust(2, '0') record = {} record[:hour] = t_hour record[:minute] = t_minute record[:second] = t_second record[:minute_description] = "#{t_hour_string}:#{t_minute_string}" record[:full_description] = "#{t_hour_string}:#{t_minute_string}:#{t_second_string}" records << record end end end records end |