Class: Opal::CliRunners::Phantomjs
- Inherits:
-
Object
- Object
- Opal::CliRunners::Phantomjs
- Defined in:
- opal/lib/opal/cli_runners/phantomjs.rb
Constant Summary
- SCRIPT_PATH =
File.('../phantom.js', __FILE__)
Instance Attribute Summary collapse
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(options) ⇒ Phantomjs
constructor
A new instance of Phantomjs.
- #run(code, argv) ⇒ Object
Constructor Details
#initialize(options) ⇒ Phantomjs
Returns a new instance of Phantomjs
8 9 10 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 8 def initialize() @output = .fetch(:output, $stdout) end |
Instance Attribute Details
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status
11 12 13 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 11 def exit_status @exit_status end |
#output ⇒ Object (readonly)
Returns the value of attribute output
11 12 13 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 11 def output @output end |
Instance Method Details
#run(code, argv) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 13 def run(code, argv) command = [ 'phantomjs', SCRIPT_PATH.shellescape, *argv.map(&:shellescape) ].join(' ') phantomjs = IO.popen(command, 'w', out: output) do |io| io.write(code) end @exit_status = $?.exitstatus end |