Class: Decode::Language::Ruby::Singleton

Inherits:
Definition
  • Object
show all
Defined in:
lib/decode/language/ruby/class.rb

Overview

A Ruby-specific singleton class.

Instance Attribute Summary

Attributes inherited from Definition

#comments, #language, #name, #parent

Instance Method Summary collapse

Methods inherited from Definition

#convert, #documentation, #initialize, #inspect, #location, #multiline?, #qualified_form, #qualified_name, #start_with?, #text

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#container?Boolean

A singleton class is a container for other definitions.

Returns:

  • (Boolean)


63
64
65
# File 'lib/decode/language/ruby/class.rb', line 63

def container?
	true
end

#nested?Boolean

Typically, a singleton class does not contain other definitions.

Returns:

  • (Boolean)


69
70
71
# File 'lib/decode/language/ruby/class.rb', line 69

def nested?
	false
end

#nested_nameObject



57
58
59
# File 'lib/decode/language/ruby/class.rb', line 57

def nested_name
	"::class"
end

#pathObject

The lexical scope as an array of names. e.g. ‘[:Decode, :Definition]`



89
90
91
92
93
94
95
96
# File 'lib/decode/language/ruby/class.rb', line 89

def path
	if @path
		# Cached version:
		@path
	else
		@path = [*self.absolute_path, *self.path_name]
	end
end

#path_nameObject



82
83
84
# File 'lib/decode/language/ruby/class.rb', line 82

def path_name
	[:class]
end

#short_formObject Also known as: long_form

The short form of the class. e.g. ‘class << self`.



75
76
77
# File 'lib/decode/language/ruby/class.rb', line 75

def short_form
	"class << #{@name}"
end