Class: SyntaxTree::Index::FileComments

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/index.rb

Overview

When you’re using the instruction sequence backend, this class is used to lazily parse comments out of the source code.

Defined Under Namespace

Classes: FileSource, Parser, StringSource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ FileComments

Returns a new instance of FileComments.



139
140
141
# File 'lib/syntax_tree/index.rb', line 139

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



137
138
139
# File 'lib/syntax_tree/index.rb', line 137

def source
  @source
end

Instance Method Details

#commentsObject



143
144
145
# File 'lib/syntax_tree/index.rb', line 143

def comments
  @comments ||= Parser.new(source.source).tap(&:parse).comments
end