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

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

Overview

A Ruby-specific class.

Instance Attribute Summary collapse

Attributes inherited from Definition

#The comment lines which directly preceeded the definition., #The language the symbol is defined within., #The path to the definition, relative to the parent., #The source file containing this definition., #comments, #language, #parent, #path, #source, #visibility

Instance Method Summary collapse

Methods inherited from Definition

#:public, :private, :protected=, #The parent definition, defining lexical scope.=, #The symbol name e.g. `:Decode`.=, #alias?, #convert, #coverage_relevant?, #documentation, #documented?, #full_path, #inspect, #location, #multiline?, #name, #nested?, #nested_name, #public?, #qualified_name, #start_with?, #text

Constructor Details

#initialize(*arguments, super_class: nil, **options) ⇒ Class

Initialize a new class definition.



17
18
19
20
21
22
23
24
# File 'lib/decode/language/ruby/class.rb', line 17

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

Instance Attribute Details

#extendsObject (readonly)

Returns the value of attribute extends.



33
34
35
# File 'lib/decode/language/ruby/class.rb', line 33

def extends
  @extends
end

#includesObject (readonly)

Returns the value of attribute includes.



30
31
32
# File 'lib/decode/language/ruby/class.rb', line 30

def includes
  @includes
end

#Modules extended into this class (adds singleton methods).(extendedintothis) ⇒ Object (readonly)



33
# File 'lib/decode/language/ruby/class.rb', line 33

attr :extends

#Modules included into this class.(includedintothis) ⇒ Object (readonly)



30
# File 'lib/decode/language/ruby/class.rb', line 30

attr :includes

#Modules prepended into this class (method lookup precedence).(prependedintothis) ⇒ Object (readonly)



36
# File 'lib/decode/language/ruby/class.rb', line 36

attr :prepends

#prependsObject (readonly)

Returns the value of attribute prepends.



36
37
38
# File 'lib/decode/language/ruby/class.rb', line 36

def prepends
  @prepends
end

#super_classObject (readonly)

Returns the value of attribute super_class.



27
28
29
# File 'lib/decode/language/ruby/class.rb', line 27

def super_class
  @super_class
end

#The super class name.(super) ⇒ Object (readonly)



27
# File 'lib/decode/language/ruby/class.rb', line 27

attr :super_class

Instance Method Details

#container?Boolean

A class is a container for other definitions.

Returns:

  • (Boolean)


39
40
41
# File 'lib/decode/language/ruby/class.rb', line 39

def container?
	true
end

#long_formObject

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



51
52
53
54
55
56
57
# File 'lib/decode/language/ruby/class.rb', line 51

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

#qualified_formObject

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



61
62
63
# File 'lib/decode/language/ruby/class.rb', line 61

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

#short_formObject

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



45
46
47
# File 'lib/decode/language/ruby/class.rb', line 45

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