Class: GoodGuide::Gibbon::Context
- Inherits:
-
Object
- Object
- GoodGuide::Gibbon::Context
- 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
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
#gibbon ⇒ Object (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 |