Class: GoodGuide::Gibbon::Context
- Inherits:
-
Object
- Object
- GoodGuide::Gibbon::Context
show all
- Includes:
- Util
- Defined in:
- lib/goodguide/gibbon.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Util
#hash_to_ruby, #obj_to_js, #obj_to_ruby
Constructor Details
#initialize(js = {}) ⇒ Context
Returns a new instance of Context.
464
465
466
467
468
469
470
471
472
|
# File 'lib/goodguide/gibbon.rb', line 464
def initialize(js={})
if js.is_a? Hash
js = JS.new(js)
end
@js = js
@defer = js[:setTimeout]
@gibbon = js.gibbon
end
|
Instance Attribute Details
#gibbon ⇒ Object
Returns the value of attribute gibbon.
462
463
464
|
# File 'lib/goodguide/gibbon.rb', line 462
def gibbon
@gibbon
end
|
#js ⇒ Object
Returns the value of attribute js.
463
464
465
|
# File 'lib/goodguide/gibbon.rb', line 463
def js
@js
end
|
Instance Method Details
#analyze(syntax, global_table, static_client) ⇒ Object
492
493
494
495
496
497
498
499
500
|
# File 'lib/goodguide/gibbon.rb', line 492
def analyze(syntax, global_table, static_client)
syntax = obj_to_js(syntax)
out = capture do |&callback|
gibbon.analyze(syntax, global_table, static_client, callback)
end
obj_to_ruby(out)
end
|
#compile(semantics) ⇒ Object
484
485
486
|
# File 'lib/goodguide/gibbon.rb', line 484
def compile(semantics)
gibbon.compile(obj_to_js(semantics))
end
|
#compile_ruby(semantics) ⇒ Object
488
489
490
|
# File 'lib/goodguide/gibbon.rb', line 488
def compile_ruby(semantics)
obj_to_ruby(gibbon.compileRuby(obj_to_js(semantics)))
end
|
#logger ⇒ Object
474
475
476
|
# File 'lib/goodguide/gibbon.rb', line 474
def logger
js.logger
end
|
#parse(str) ⇒ Object
478
479
480
481
482
|
# File 'lib/goodguide/gibbon.rb', line 478
def parse(str)
obj_to_ruby self.gibbon.parse(str)
rescue JSError => e
raise SemanticError.new([{'_tag' => 'parse', 'message' => e.value}], self)
end
|