Class: Quby::Compiler::Services::TransformQuby1ValuesIntoQuby2Values
- Inherits:
-
Object
- Object
- Quby::Compiler::Services::TransformQuby1ValuesIntoQuby2Values
- Defined in:
- lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb
Overview
Copied from RoQua for default_answer_values. Temporary: should change the values when quby1 is off the table
Instance Attribute Summary collapse
-
#questionnaire ⇒ Object
Returns the value of attribute questionnaire.
-
#values ⇒ Object
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute ⇒ Object
Edits hash in place! extra v_3 key is not in quby1, but can’t really hurt keeping it in.
-
#initialize(questionnaire, values) ⇒ TransformQuby1ValuesIntoQuby2Values
constructor
A new instance of TransformQuby1ValuesIntoQuby2Values.
Constructor Details
#initialize(questionnaire, values) ⇒ TransformQuby1ValuesIntoQuby2Values
Returns a new instance of TransformQuby1ValuesIntoQuby2Values.
12 13 14 15 |
# File 'lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb', line 12 def initialize(questionnaire, values) @questionnaire = questionnaire @values = (values || {}).with_indifferent_access end |
Instance Attribute Details
#questionnaire ⇒ Object
Returns the value of attribute questionnaire.
6 7 8 |
# File 'lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb', line 6 def questionnaire @questionnaire end |
#values ⇒ Object
Returns the value of attribute values.
6 7 8 |
# File 'lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb', line 6 def values @values end |
Class Method Details
.run! ⇒ Object
8 9 10 |
# File 'lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb', line 8 def self.run!(...) new(...).execute end |
Instance Method Details
#execute ⇒ Object
Edits hash in place! extra v_3 key is not in quby1, but can’t really hurt keeping it in. {year: ‘2020’} to => ‘2020’, v_3: {year: ‘2020’} [‘a2’] to 0, v_4_a2: 1, v_4: {v_4_a1: 0, v_4_a2: 1}
21 22 23 24 25 26 27 28 29 |
# File 'lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb', line 21 def execute questionnaire.questions.each do |question| case question.type when :date then transform_date_parts(question) when :check_box then transform_multi_select(question) end end values end |