Module: Duby::AST::Scoped

Instance Method Summary collapse

Instance Method Details

#containing_scopeObject



217
218
219
220
221
222
223
# File 'lib/duby/ast.rb', line 217

def containing_scope
  scope = self.scope.static_scope
  while scope.parent && scope.parent.include?(name)
    scope = scope.parent
  end
  scope
end

#scopeObject



206
207
208
209
210
211
212
213
214
215
# File 'lib/duby/ast.rb', line 206

def scope
  @scope ||= begin
    scope = parent
    raise "No parent for #{self.class.name} at #{line_number}" if scope.nil?
    until scope.class.include?(Scope)
      scope = scope.parent
    end
    scope
  end
end