Class: Decode::Language::Ruby::Constant
- Inherits:
-
Definition
- Object
- Symbol
- 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
Attributes inherited from Symbol
#kind, #language, #name, #parent
Instance Method Summary collapse
-
#long_form ⇒ Object
The long form of the constant.
-
#short_form ⇒ Object
The short form of the constant.
Methods inherited from Definition
#container?, #documentation, #initialize, #multiline?, #nested?, #qualified_form, #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
#long_form ⇒ Object
The long form of the constant. e.g. ‘NAME = “Alice”`.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/decode/language/ruby/constant.rb', line 36 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 |
#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 |