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

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

Overview

A Ruby-specific module.

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, **options) ⇒ Module

Initialize a module with its name and options.



14
15
16
17
18
19
20
# File 'lib/decode/language/ruby/module.rb', line 14

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

Instance Attribute Details

#extendsObject (readonly)

Returns the value of attribute extends.



26
27
28
# File 'lib/decode/language/ruby/module.rb', line 26

def extends
  @extends
end

#includesObject (readonly)

Returns the value of attribute includes.



23
24
25
# File 'lib/decode/language/ruby/module.rb', line 23

def includes
  @includes
end

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



26
# File 'lib/decode/language/ruby/module.rb', line 26

attr :extends

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



23
# File 'lib/decode/language/ruby/module.rb', line 23

attr :includes

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



29
# File 'lib/decode/language/ruby/module.rb', line 29

attr :prepends

#prependsObject (readonly)

Returns the value of attribute prepends.



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

def prepends
  @prepends
end

Instance Method Details

#container?Boolean

A module is a container for other definitions.

Returns:

  • (Boolean)


32
33
34
# File 'lib/decode/language/ruby/module.rb', line 32

def container?
	true
end

#long_formObject

Generate a long form representation of the module.



43
44
45
# File 'lib/decode/language/ruby/module.rb', line 43

def long_form
	qualified_form
end

#qualified_formObject

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



49
50
51
# File 'lib/decode/language/ruby/module.rb', line 49

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

#short_formObject

The short form of the module. e.g. ‘module Barnyard`.



38
39
40
# File 'lib/decode/language/ruby/module.rb', line 38

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