Class: Cure::Transformation::Transform
- Inherits:
-
Object
- Object
- Cure::Transformation::Transform
- Includes:
- Configuration, Helpers::FileHelpers, Log
- Defined in:
- lib/cure/transformation/transform.rb
Overview
Operational file for conducting transforms
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(candidates) ⇒ Transform
constructor
A new instance of Transform.
-
#transform_content(parsed_content) ⇒ Hash<String,TransformResult>
# make this transformation results?.
Methods included from Configuration
#config, #create_config, #register_config
Methods included from Helpers::FileHelpers
#clean_dir, #read_file, #with_file, #with_temp_dir
Methods included from Log
#log_debug, #log_error, #log_info, #log_warn
Constructor Details
#initialize(candidates) ⇒ Transform
Returns a new instance of Transform.
22 23 24 |
# File 'lib/cure/transformation/transform.rb', line 22 def initialize(candidates) @candidates = candidates end |
Instance Attribute Details
#candidates ⇒ Array<Candidate>
19 20 21 |
# File 'lib/cure/transformation/transform.rb', line 19 def candidates @candidates end |
Instance Method Details
#transform_content(parsed_content) ⇒ Hash<String,TransformResult>
Returns # make this transformation results?.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cure/transformation/transform.rb', line 28 def transform_content(parsed_content) parsed_content.content.each_with_object({}) do |section, hash| ctx = TransformResult.new section["rows"].each do |row| ctx.row_count += 1 if ctx.row_count == 1 ctx.extract_column_headers(row) next end row = transform(section["name"], ctx.column_headers, row) ctx.add_transformed_row(row) end hash[section["name"]] = ctx end end |