Class: Decode::Language::Ruby::Segment

Inherits:
Segment
  • Object
show all
Defined in:
lib/decode/language/ruby/segment.rb

Overview

A Ruby specific code segment.

Instance Attribute Summary collapse

Attributes inherited from Segment

#comments, #language

Instance Method Summary collapse

Methods inherited from Segment

#documentation

Constructor Details

#initialize(comments, language, node, **options) ⇒ Segment

Returns a new instance of Segment.



28
29
30
31
32
33
# File 'lib/decode/language/ruby/segment.rb', line 28

def initialize(comments, language, node, **options)
	super(comments, language, **options)
	
	@node = node
	@expression = node.location.expression
end

Instance Attribute Details

#nodeObject (readonly)

The parser syntax tree node.



36
37
38
# File 'lib/decode/language/ruby/segment.rb', line 36

def node
  @node
end

Instance Method Details

#codeObject

The source code trailing the comments.



44
45
46
# File 'lib/decode/language/ruby/segment.rb', line 44

def code
	@expression.source
end

#expand(node) ⇒ Object



38
39
40
# File 'lib/decode/language/ruby/segment.rb', line 38

def expand(node)
	@expression = @expression.join(node.location.expression)
end