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`.=, #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
# File 'lib/decode/language/ruby/class.rb', line 17

def initialize(*arguments, super_class: nil, **options)
  super(*arguments, **options)
  
  @super_class = super_class
end

Instance Attribute Details

#super_classObject (readonly)

Returns the value of attribute super_class.



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

def super_class
  @super_class
end

Instance Method Details

#container?Boolean

A class is a container for other definitions.

Returns:

  • (Boolean)


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

def container?
  true
end

#long_formObject

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



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

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`.



48
49
50
# File 'lib/decode/language/ruby/class.rb', line 48

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

#short_formObject

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



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

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