Class: Melbourne::AST::Class

Inherits:
Node
  • Object
show all
Defined in:
lib/melbourne/ast/definitions.rb

Overview

A class as in:

class X; end

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, name, superclass, body) ⇒ Class



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/melbourne/ast/definitions.rb', line 311

def initialize(line, name, superclass, body)
  @line = line

  @superclass = superclass ? superclass : Nil.new(line)

  if name.kind_of? Symbol
    @name = ClassName.new line, name, @superclass
  else
    @name = ScopedClassName.new line, name, @superclass
  end

  if body
    @body = ClassScope.new line, @name, body
  else
    @body = EmptyBody.new line
  end
end

Instance Attribute Details

#bodyObject

The body of the class



309
310
311
# File 'lib/melbourne/ast/definitions.rb', line 309

def body
  @body
end

#nameObject

The name of the class



301
302
303
# File 'lib/melbourne/ast/definitions.rb', line 301

def name
  @name
end

#superclassObject

The superclass of the class



305
306
307
# File 'lib/melbourne/ast/definitions.rb', line 305

def superclass
  @superclass
end