Class: GoodGuide::Gibbon::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/goodguide/gibbon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(js = {}) ⇒ Context

Returns a new instance of Context.



172
173
174
175
176
177
178
# File 'lib/goodguide/gibbon.rb', line 172

def initialize(js={})
  if js.is_a? Hash
    js = JS.new(js)
  end

  @gibbon = js.gibbon
end

Instance Attribute Details

#gibbonObject (readonly)

Returns the value of attribute gibbon.



171
172
173
# File 'lib/goodguide/gibbon.rb', line 171

def gibbon
  @gibbon
end

Instance Method Details

#analyze(syntax, global_table, static_client) ⇒ Object



184
185
186
187
188
189
190
# File 'lib/goodguide/gibbon.rb', line 184

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



192
193
194
195
196
197
198
199
# File 'lib/goodguide/gibbon.rb', line 192

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



180
181
182
# File 'lib/goodguide/gibbon.rb', line 180

def parse(str)
  obj_to_ruby self.gibbon.parse(str).asJSON
end