Class: Mutineer::Project::SubjectVisitor::WrittenName

Inherits:
String
  • Object
show all
Defined in:
lib/mutineer/project.rb

Overview

A name that reads like a constant name but may not be one (#216). It is the singleton class name of a class << self opened inside a def or a block that does not build a class, or built on a written path or #<anonymous> (#<Class:Foo::X> from class Foo::X inside class << self); or the X of module self::X or self::X = ... in a def or a block. The segment carries that mark (see #singleton_name, #with_namespace, #assigned_owner), and scope, the def or block whose self the name is under, or a new object when unknown.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, scope = Object.new) ⇒ WrittenName

Returns a new instance of WrittenName.

Parameters:

  • name (String) —

    the name as built.

  • scope (Object) (defaults to: Object.new) —

    the def or block node whose self the name is under.



193
194
195
196
# File 'lib/mutineer/project.rb', line 193

def initialize(name, scope = Object.new)
  super(name)
  @scope = scope
end

Instance Attribute Details

#scope ⇒ Object (readonly)

Returns the def or block node whose self the name is under.

Returns:

  • (Object) —

    the def or block node whose self the name is under.



189
190
191
# File 'lib/mutineer/project.rb', line 189

def scope
  @scope
end