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

Attributes inherited from Definition

#comments

Attributes inherited from Symbol

#kind, #language, #name, #parent

Instance Method Summary collapse

Methods inherited from Definition

#documentation, #initialize, #multiline?, #nested?, #text

Methods inherited from Symbol

#initialize, #inspect, #key, #lexical_path, #path, #qualified_name

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#container?Boolean

A class is a container for other definitions.

Returns:

  • (Boolean)


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

def container?
	true
end

#long_formObject

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



41
42
43
44
45
46
47
48
49
# File 'lib/decode/language/ruby/class.rb', line 41

def long_form
	if super_node = @node.children[1]
		@node.location.keyword.join(
			super_node.location.expression
		).source
	else
		self.short_form
	end
end

#qualified_formObject

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



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

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

#short_formObject

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



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

def short_form
	"class #{@name}"
end