Class: Decode::Language::Ruby::Class
- Inherits:
-
Definition
- Object
- Definition
- Decode::Language::Ruby::Class
- Defined in:
- lib/decode/language/ruby/class.rb
Overview
A Ruby-specific class.
Instance Attribute Summary
Attributes inherited from Definition
#comments, #language, #name, #parent
Instance Method Summary collapse
-
#container? ⇒ Boolean
A class is a container for other definitions.
-
#long_form ⇒ Object
The long form of the class.
- #nested_name ⇒ Object
- #path_name ⇒ Object
-
#qualified_form ⇒ Object
The fully qualified name of the class.
-
#short_form ⇒ Object
The short form of the class.
- #super_class ⇒ Object
Methods inherited from Definition
#convert, #documentation, #initialize, #inspect, #location, #multiline?, #nested?, #path, #qualified_name, #start_with?, #text
Constructor Details
This class inherits a constructor from Decode::Definition
Instance Method Details
#container? ⇒ Boolean
A class is a container for other definitions.
14 15 16 |
# File 'lib/decode/language/ruby/class.rb', line 14 def container? true end |
#long_form ⇒ Object
The long form of the class. e.g. ‘class Dog < Animal`.
30 31 32 33 34 35 36 |
# File 'lib/decode/language/ruby/class.rb', line 30 def long_form if super_class = self.super_class "#{qualified_form} < #{super_class}" else qualified_form end end |
#nested_name ⇒ Object
18 19 20 |
# File 'lib/decode/language/ruby/class.rb', line 18 def nested_name "::#{name}" end |
#path_name ⇒ Object
50 51 52 |
# File 'lib/decode/language/ruby/class.rb', line 50 def path_name @name.to_s.split('::').map(&:to_sym) end |
#qualified_form ⇒ Object
The fully qualified name of the class. e.g. ‘class ::Barnyard::Dog`.
46 47 48 |
# File 'lib/decode/language/ruby/class.rb', line 46 def qualified_form "class #{self.qualified_name}" end |
#short_form ⇒ Object
The short form of the class. e.g. ‘class Animal`.
24 25 26 |
# File 'lib/decode/language/ruby/class.rb', line 24 def short_form "class #{path_name.last}" end |
#super_class ⇒ Object
38 39 40 41 42 |
# File 'lib/decode/language/ruby/class.rb', line 38 def super_class if super_node = @node.children[1] super_node.location.expression.source end end |