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.
375
376
377
378
379
380
381
382
|
# File 'lib/goodguide/gibbon.rb', line 375
def initialize(js={})
if js.is_a? Hash
js = JS.new(js)
end
@defer = js[:setTimeout]
@gibbon = js.gibbon
end
|
Instance Attribute Details
#gibbon ⇒ Object
Returns the value of attribute gibbon.
374
375
376
|
# File 'lib/goodguide/gibbon.rb', line 374
def gibbon
@gibbon
end
|
Instance Method Details
#analyze(syntax, global_table, static_client) ⇒ Object
394
395
396
397
398
399
400
|
# File 'lib/goodguide/gibbon.rb', line 394
def analyze(syntax, global_table, static_client)
syntax = obj_to_js(syntax)
capture do |&callback|
gibbon.analyze(syntax, global_table, static_client, callback)
end
end
|
#compile(semantics) ⇒ Object
390
391
392
|
# File 'lib/goodguide/gibbon.rb', line 390
def compile(semantics)
gibbon.compile(obj_to_js(semantics))
end
|
#parse(str) ⇒ Object
384
385
386
387
388
|
# File 'lib/goodguide/gibbon.rb', line 384
def parse(str)
obj_to_ruby self.gibbon.parse(str)
rescue JSError => e
raise SemanticError.new([{'_tag' => 'parse', 'message' => e.value}], self)
end
|
#run_compiled(compiled, entity_id, runtime_client) ⇒ Object
402
403
404
405
406
407
408
|
# File 'lib/goodguide/gibbon.rb', line 402
def run_compiled(compiled, entity_id, runtime_client)
values, error = capture do |&callback|
compiled.run('/', entity_id, runtime_client, callback)
end
[hash_to_ruby(values), obj_to_ruby(error)]
end
|