Class: EleetScript::MethodContext

Inherits:
BaseContext show all
Defined in:
lib/lang/runtime/context.rb

Instance Attribute Summary collapse

Attributes inherited from BaseContext

#constants, #current_class, #current_self, #global_vars, #local_vars, #namespaces

Instance Method Summary collapse

Methods inherited from BaseContext

#[], #[]=, #class_vars, #es_nil, init_with, #initialize, #instance_vars, #local_constant, #method_missing, #respond_to_missing?, #root_ns

Constructor Details

This class inherits a constructor from EleetScript::BaseContext

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EleetScript::BaseContext

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



281
282
283
# File 'lib/lang/runtime/context.rb', line 281

def name
  @name
end

Instance Method Details

#lambda?Boolean

Returns:

  • (Boolean)


308
309
310
# File 'lib/lang/runtime/context.rb', line 308

def lambda?
  !@lambda_context.nil?
end

#local_var(name, value = nil) ⇒ Object



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/lang/runtime/context.rb', line 285

def local_var(name, value = nil)
  if value
    if @lambda_context && @lambda_context.local_var(name)
      @lambda_context.local_var(name, value)
    else
      local_vars[name] = value
    end
  else
    val = super
    if val == es_nil && @lambda_context
      @lambda_context.local_var(name)
    elsif val
      val
    else
      es_nil
    end
  end
end

#namespace_contextObject



304
305
306
# File 'lib/lang/runtime/context.rb', line 304

def namespace_context
  @parent_context.namespace_context
end