Class: Csvtool::Interface::CLI::Workflows::Steps::RowRandomization::CollectInputsStep
- Inherits:
-
Object
- Object
- Csvtool::Interface::CLI::Workflows::Steps::RowRandomization::CollectInputsStep
- Defined in:
- lib/csvtool/interface/cli/workflows/steps/row_randomization/collect_inputs_step.rb
Instance Method Summary collapse
- #call(context) ⇒ Object
-
#initialize(file_path_prompt:, separator_prompt:, headers_present_prompt:, seed_prompt:) ⇒ CollectInputsStep
constructor
A new instance of CollectInputsStep.
Constructor Details
#initialize(file_path_prompt:, separator_prompt:, headers_present_prompt:, seed_prompt:) ⇒ CollectInputsStep
Returns a new instance of CollectInputsStep.
10 11 12 13 14 15 |
# File 'lib/csvtool/interface/cli/workflows/steps/row_randomization/collect_inputs_step.rb', line 10 def initialize(file_path_prompt:, separator_prompt:, headers_present_prompt:, seed_prompt:) @file_path_prompt = file_path_prompt @separator_prompt = separator_prompt @headers_present_prompt = headers_present_prompt @seed_prompt = seed_prompt end |
Instance Method Details
#call(context) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/csvtool/interface/cli/workflows/steps/row_randomization/collect_inputs_step.rb', line 17 def call(context) file_path = @file_path_prompt.call col_sep = @separator_prompt.call return :halt if col_sep.nil? headers_present = @headers_present_prompt.call header_result = context.fetch(:use_case).read_headers( file_path: file_path, col_sep: col_sep, headers_present: headers_present ) unless header_result.ok? context.fetch(:handle_error).call(header_result) return :halt end seed = @seed_prompt.call return :halt if seed == Interface::CLI::Prompts::SeedPrompt::INVALID context[:file_path] = file_path context[:col_sep] = col_sep context[:headers_present] = headers_present context[:headers] = header_result.data[:headers] context[:seed] = seed nil end |