Class: OpalRacer

Inherits:
Object
  • Object
show all
Defined in:
lib/opalracer.rb

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOpalRacer

Returns a new instance of OpalRacer.



11
12
13
14
15
16
# File 'lib/opalracer.rb', line 11

def initialize
  @builder = Opal::Builder.new
  @v8 = V8::Context.new
  @v8['console'] = self
  @v8.eval self.class.opal_build
end

Class Method Details

.opal_buildObject



7
8
9
# File 'lib/opalracer.rb', line 7

def self.opal_build
  @opal_build ||= Opal::Builder.new.build('opal').to_s
end

Instance Method Details

#eval_ruby(ruby, file: nil) ⇒ Object



22
23
24
25
# File 'lib/opalracer.rb', line 22

def eval_ruby(ruby, file: nil)
  file ||= __FILE__
  @v8.eval Opal::Builder.new.build_str(ruby, file)
end

#log(*str) ⇒ Object



18
19
20
# File 'lib/opalracer.rb', line 18

def log(*str)
  puts(*str)
end