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.
249 250 251 252 253 254 255 |
# File 'lib/goodguide/gibbon.rb', line 249 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.
248 249 250 |
# File 'lib/goodguide/gibbon.rb', line 248 def gibbon @gibbon end |
Instance Method Details
#analyze(syntax, global_table, static_client) ⇒ Object
261 262 263 264 265 266 267 |
# File 'lib/goodguide/gibbon.rb', line 261 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
269 270 271 272 273 274 275 276 |
# File 'lib/goodguide/gibbon.rb', line 269 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
257 258 259 |
# File 'lib/goodguide/gibbon.rb', line 257 def parse(str) obj_to_ruby self.gibbon.parse(str).asJSON end |