Running Ruby assembly code via Sublime Command Line

Is it possible to inject my ruby ​​code into sublime, then run the build, open the command prompt in sublime, and actually execute the code you just built? I read conflicting things if this is how he thinks to work or not. Found an older thread from July here that asked the same question, but it seemed like the person just wanted to know why it was puts

not starting when it ran a "build".

To give a better example of what I was curious about you can do in Sublime if I wrote it in sublime

class BookInStock
    def initialize(isbn, price)
        @isbn = isbn
        @price = Float(price)
    end
    def to_S
        "ISBN: #{@isbn}, price: #{@price}"
    end
end

      

Then I saved it and ran the build. Then opened a Sublime line and typed book = BookInStore.new("what","ever)

, then launched puts book

and returned something.

I hope this is possible. I mean typing in some text, then saving it and then going to terminal to run, that's not bad, just would like to do it from Sublime.

+3


source to share


1 answer


Yes it is possible. However, Sublime Text will require a plugin. This plugin is called SublimeREPL . I've been using it for quite some time now and it accomplishes what you are trying to achieve.

After installing the plugin (check the page I linked to for instructions) you can run your code in ruby ​​interpreter in Sublime Text by doing the following:



  • Start the plugin with "Ctrl + shift + p" and search for "SublimeRepl: ruby". Hit Enter.
  • Open the tab with the ruby ​​code you want to use in the interpreter
  • Press "Ctrl + [comma], f" --- (ctrl plus comma followed by f key)
  • Go to the tab that opened when the plugin was launched and you can now instantiate your class in the interpreter.

enter image description here

0


source







All Articles