Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 220863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:58:45+00:00 2026-05-11T18:58:45+00:00

I am refactoring some code that I did not write, and I found a

  • 0

I am refactoring some code that I did not write, and I found a line that looks like this (it is much longer, i used just a little bit for this example):

system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control');")

To increase readability, I refactored it to

do_something =
  "rubyw -e \"
    require 'win32ole'
    @autoit=WIN32OLE.new('AutoItX3.Control')"
system do_something

Then I wanted to make some changes, but since the code I am working on is in a string, I lose syntax highlighting, parenthesis matching and all that good stuff.

Is there an easy way to write some code outside of the string and then convert it to string?

I have searched the web and stackoverflow, but could not find the answer.

For more information, take a look at original code at bret/watir (Watir::FileField#set, line 445), and my fork at zeljkofilipin/watir (lines 447-459).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:58:45+00:00Added an answer on May 11, 2026 at 6:58 pm

    You can use the following syntax:

    do_something = <<SOMETHING
      rubyw -e 
      require 'win32ole'
      @autoit=WIN32OLE.new('AutoItX3.Control')
    SOMETHING
    

    Apparently it’s a heredoc! You can find another example here(doc).

    That’s not to say that the command won’t freak out about having line breaks in there. However you could likely run it by system do_something.split(/\r\n/).join('') or something like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Found it. I should use iconv function: :call mkdir(iconv("привет", "utf-8",… May 13, 2026 at 5:55 pm
  • Editorial Team
    Editorial Team added an answer You should specialize the new_clone and delete_clone functions as described… May 13, 2026 at 5:55 pm
  • Editorial Team
    Editorial Team added an answer You definitely want the grid manager -- Pack only works… May 13, 2026 at 5:55 pm

Related Questions

I want to mock a ResultSet. Seriously. I'm refactoring one big complicated piece of
Having read Fowler's Refactoring for a while, I still often catch myself thinking I
I have a web app in production that is used for typical data entry,retrieval,
so after a few weeks, i have got my head around asp.net mvc and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.