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.
243 244 245 246 247 248 249 |
# File 'lib/goodguide/gibbon.rb', line 243 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.
242 243 244 |
# File 'lib/goodguide/gibbon.rb', line 242 def gibbon @gibbon end |
Instance Method Details
#analyze(syntax, global_table, static_client) ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/goodguide/gibbon.rb', line 255 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
263 264 265 266 267 268 269 270 |
# File 'lib/goodguide/gibbon.rb', line 263 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
251 252 253 |
# File 'lib/goodguide/gibbon.rb', line 251 def parse(str) obj_to_ruby self.gibbon.parse(str).asJSON end |