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.



113
114
115
# File 'lib/syntax_tree/index.rb', line 113

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



111
112
113
# File 'lib/syntax_tree/index.rb', line 111

def source
  @source
end

Instance Method Details

#commentsObject



117
118
119
# File 'lib/syntax_tree/index.rb', line 117

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