DecodeSourceDecodeLanguageRubyClass

class Class

A Ruby-specific class.

Definitions

def initialize(*arguments, super_class: nil, **options)

Initialize a new class definition.

Signature

parameter arguments Array

The definition arguments.

parameter super_class String

The super class name.

parameter options Hash

Additional options.

Implementation

def initialize(*arguments, super_class: nil, **options)
	super(*arguments, **options)
	
	@super_class = super_class
	@includes = []
	@extends = []
	@prepends = []
end

attr :super_class

Signature

attribute String?

The super class name.

attr :includes

Signature

attribute Array(Symbol)

Modules included into this class.

attr :extends

Signature

attribute Array(Symbol)

Modules extended into this class (adds singleton methods).

attr :prepends

Signature

attribute Array(Symbol)

Modules prepended into this class (method lookup precedence).

def container?

A class is a container for other definitions.

Implementation

def container?
	true
end

def short_form

The short form of the class. e.g. class Animal.

Implementation

def short_form
	"class #{self.name}"
end

def long_form

The long form of the class. e.g. class Dog < Animal.

Implementation

def long_form
	if super_class = self.super_class
		"#{qualified_form} < #{super_class}"
	else
		qualified_form
	end
end

def qualified_form

The fully qualified name of the class. e.g. class ::Barnyard::Dog.

Implementation

def qualified_form
	"class #{self.qualified_name}"
end