Last active
June 18, 2020 08:14
-
-
Save cpoo22/0adb618793996f7d99ade2237f5f4951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Extractor | |
def strip(field) | |
field&.gsub(/\n/, " ")&.gsub(/<.*?>/, "") | |
end | |
def extract(vertical) | |
questionnaire = X_Rated::Quoting::ChopinEngine.questionnaire_for({ Site: 'uk' }, vertical: vertical) | |
qs = questionnaire.questions(unasked: true) | |
mapped_qs = qs.map { |q| [q.name, strip(q.primary_text), strip(q.secondary_text), strip(q.help_text), q.document_section, q.category, q.type, q.tags] } | |
CSV.open("file.csv", "wb") do |csv| | |
mapped_qs.each do |q| | |
csv << q; | |
end; | |
end; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment