Class: Decode::Language::Ruby::Segment
- Defined in:
- lib/decode/language/ruby/segment.rb
Overview
A Ruby specific code segment.
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
The parser syntax tree node.
Attributes inherited from Segment
Instance Method Summary collapse
-
#code ⇒ Object
The source code trailing the comments.
- #expand(node) ⇒ Object
-
#initialize(comments, language, node, **options) ⇒ Segment
constructor
A new instance of Segment.
Methods inherited from Segment
Constructor Details
#initialize(comments, language, node, **options) ⇒ Segment
Returns a new instance of Segment.
13 14 15 16 17 18 |
# File 'lib/decode/language/ruby/segment.rb', line 13 def initialize(comments, language, node, **) super(comments, language, **) @node = node @expression = node.location.expression end |
Instance Attribute Details
#node ⇒ Object (readonly)
The parser syntax tree node.
21 22 23 |
# File 'lib/decode/language/ruby/segment.rb', line 21 def node @node end |
Instance Method Details
#code ⇒ Object
The source code trailing the comments.
29 30 31 |
# File 'lib/decode/language/ruby/segment.rb', line 29 def code @expression.source end |
#expand(node) ⇒ Object
23 24 25 |
# File 'lib/decode/language/ruby/segment.rb', line 23 def (node) @expression = @expression.join(node.location.expression) end |