Class: GoodGuide::Gibbon::Context
- Inherits:
-
Object
- Object
- GoodGuide::Gibbon::Context
- Includes:
- Util
- Defined in:
- lib/goodguide/gibbon.rb
Instance Attribute Summary collapse
-
#gibbon ⇒ Object
readonly
Returns the value of attribute gibbon.
Instance Method Summary collapse
- #analyze(syntax, global_table, static_client) ⇒ Object
- #eval_gibbon(semantics, id, runtime_client) ⇒ Object
-
#initialize(js = {}) ⇒ Context
constructor
A new instance of Context.
- #parse(str) ⇒ Object
Methods included from Util
#hash_to_js, #hash_to_ruby, #obj_to_ruby
Constructor Details
#initialize(js = {}) ⇒ Context
Returns a new instance of Context.
271 272 273 274 275 276 277 |
# File 'lib/goodguide/gibbon.rb', line 271 def initialize(js={}) if js.is_a? Hash js = JS.new(js) end @gibbon = js.gibbon end |
Instance Attribute Details
#gibbon ⇒ Object (readonly)
Returns the value of attribute gibbon.
270 271 272 |
# File 'lib/goodguide/gibbon.rb', line 270 def gibbon @gibbon end |
Instance Method Details
#analyze(syntax, global_table, static_client) ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/goodguide/gibbon.rb', line 283 def analyze(syntax, global_table, static_client) semantics, error = capture do |&callback| gibbon.analyze(syntax, global_table, static_client, callback) end [hash_to_ruby(semantics), obj_to_ruby(error)] end |
#eval_gibbon(semantics, id, runtime_client) ⇒ Object
291 292 293 294 295 296 297 298 |
# File 'lib/goodguide/gibbon.rb', line 291 def eval_gibbon(semantics, id, runtime_client) semantics = hash_to_js(semantics) values, error = capture do |&callback| gibbon.eval(semantics, 0, id, runtime_client, callback) end [hash_to_ruby(values), obj_to_ruby(error)] end |
#parse(str) ⇒ Object
279 280 281 |
# File 'lib/goodguide/gibbon.rb', line 279 def parse(str) obj_to_ruby self.gibbon.parse(str).asJSON end |