Class: Decode::Language::Ruby::Constant
- Inherits:
-
Definition
- Object
- Definition
- Decode::Language::Ruby::Constant
- Defined in:
- lib/decode/language/ruby/constant.rb
Overview
A Ruby-specific constant.
Instance Attribute Summary
Attributes inherited from Definition
#comments, #language, #name, #parent
Instance Method Summary collapse
-
#long_form ⇒ Object
The long form of the constant.
- #nested_name ⇒ Object
-
#short_form ⇒ Object
The short form of the constant.
Methods inherited from Definition
#container?, #convert, #documentation, #initialize, #multiline?, #nested?, #path, #qualified_form, #qualified_name, #start_with?, #text, #to_s
Constructor Details
This class inherits a constructor from Decode::Definition
Instance Method Details
#long_form ⇒ Object
The long form of the constant. e.g. ‘NAME = “Alice”`.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/decode/language/ruby/constant.rb', line 40 def long_form if @node.location.line == @node.location.last_line @node.location.expression.source elsif @node.children[2].type == :array "#{@name} = [...]" elsif @node.children[2].type == :hash "#{@name} = {...}" else self.short_form end end |
#nested_name ⇒ Object
34 35 36 |
# File 'lib/decode/language/ruby/constant.rb', line 34 def nested_name "::#{@name}" end |
#short_form ⇒ Object
The short form of the constant. e.g. ‘NAME`.
30 31 32 |
# File 'lib/decode/language/ruby/constant.rb', line 30 def short_form @node.location.name.source end |