temp = IdCardBenefitsTemplate.create(title: "Testing Template") (1..14).each do |bene| IdCardBenefit.create(sequence: bene, benefit: "value_#{bene}", id_card_benefits_template: temp) end 3.times do |i| puts i end
co
ve
co
ve
co
ve
co
ve
co
ve
co
doc = Docx::Document.open('tmp/BRYAN PEST CONTROL ID CARD SET UP REVISION.docx') data_lines = doc.paragraphs.map { |p| p.to_s.strip }.reject!(&:empty?) data_lines.each_with_index do |p, i| if p.to_s.length > 1 puts "-#{i}----------------------------------------------------------" puts p end end doc.bookmarks.each_pair do |bookmark_name, bookmark_object| puts bookmark_object.text end data_lines.index { |s| s == 'Medical Plan'} Zip::File.open('tmp/BRYAN PEST CONTROL ID CARD SET UP REVISION.docx') do |zip_file| zip_file.each do |entry| if entry.name.start_with?('word/media/') && !entry.directory? filename = File.basename(entry.name) image_data = entry.get_input_stream.read extracted_images << { filename: filename, data: image_data } end end end Sitation [8,9,10,15,19,40] plan 1 [48..62] plan 2 [65..79] plan 3 [85..99] Bryan group_number employer_name effect_date logo_name plans: same as template process: { } BenefitsWordDocProcessor.new('tmp/BRYAN PEST CONTROL ID CARD SET UP REVISION.docx').call sample_id_cards rails g model SampleIdCard family_id:string network_image:string pl_plan_key:integer primary_mb_member_key:integer employer_name:string full_name:string medical_eff_date:string provider_code:string provider_line_1:string provider_line_2:string provider_line_3:string provider_line_4:string provider_line_5:string provider_line_6:string provider_line_7:string provider_line_8:string provider_line_9:string provider_line_10:string provider_line_11:string mail_to:string claim_to_1:string claim_to_2:string claim_to_3:string claim_to_4:string claim_to_5:string claim_to_6:string claim_to_7:string claim_to_8:string claim_to_9:string claim_to_10:string claim_to_11:string group_number:string rx_group:string customer_service:string web_url:string dependent_1:string dependent_2:string dependent_3:string dependent_4:string dependent_5:string dependent_6:string dependent_7:string dependent_8:string benefit_desc_1:string benefit_1:string benefit_desc_2:string benefit_2:string benefit_desc_3:string benefit_3:string benefit_desc_4:string benefit_4:string benefit_desc_5:string benefit_5:string benefit_desc_6:string benefit_6:string benefit_desc_7:string benefit_7:string benefit_desc_8:string benefit_8:string benefit_desc_9:string benefit_9:string benefit_desc_10:string benefit_10:string benefit_desc_11:string benefit_11:string benefit_desc_12:string benefit_12:string benefit_desc_13:string benefit_13:string benefit_desc_14:string benefit_14:string :provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6, :provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6, :claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11 claim_to temp = IdCardBenefitsTemplate.first seed_data = temp.attributes.except("id", "created_at", "updated_at") seed_data_bene = temp.id_card_benefits.order(:sequence).pluck(:benefit) IdCardBenefitsTemplate.find() IdCardBenefitsTemplate.where(id: IdCardBenefitsTemplate.group(:user_id).select('MAX(id)')) BenefitsWordDocProcessor.new('').call e_names = EmployerSetupProcess.where.not(employer_name: [nil, ""]).pluck(:employer_name).uniq substrings_to_remove = ["health plan", "the", "inc", "llc"] regex = Regexp.union(substrings_to_remove) trimmed_e_names = e_names.map { |e_name| e_name.downcase.gsub(regex, "").squish } sql_query = "SELECT PLPlanKey, PlanId, Company FROM PLPlanHeader WHERE PLPlanKey >= 58" plan_headers = VhcsRecord.connection.select_all(sql_query) trimmed_e_names.each do |e_name| match = plan_headers.select { |ph| e_name.downcase.include?(ph["Company"].downcase) || ph["Company"].downcase.include?(e_name.downcase) } if match.present? puts match else puts "#{e_name} not matched" end end original_string = "How to chop an onion? This is a test string." substrings_to_remove = ["to", "an", "a", "the"] # Create a regular expression from the array of substrings, # using the | (OR) operator to match any of them. # The `\b` word boundary ensures that "an" in "another" isn't removed. regex = Regexp.union(substrings_to_remove.map { |s| /\b#{Regexp.escape(s)}\b/ }) # Use gsub with the regular expression to replace all occurrences with an empty string. cleaned_string = original_string.gsub(regex, '')