Skip to content

Instantly share code, notes, and snippets.

@cpoo22
Last active June 18, 2020 08:14
Show Gist options
  • Save cpoo22/0adb618793996f7d99ade2237f5f4951 to your computer and use it in GitHub Desktop.
Save cpoo22/0adb618793996f7d99ade2237f5f4951 to your computer and use it in GitHub Desktop.
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