Class: CommentExtractor
- Inherits:
-
Object
- Object
- CommentExtractor
- Defined in:
- lib/tom_extract/comment_extractor.rb
Instance Method Summary collapse
- #comment ⇒ Object
-
#initialize(pathname, line_number) ⇒ CommentExtractor
constructor
A new instance of CommentExtractor.
Constructor Details
#initialize(pathname, line_number) ⇒ CommentExtractor
Returns a new instance of CommentExtractor.
3 4 5 |
# File 'lib/tom_extract/comment_extractor.rb', line 3 def initialize(pathname, line_number) @pathname, @line_number = pathname, line_number end |
Instance Method Details
#comment ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/tom_extract/comment_extractor.rb', line 7 def comment c = [] source[0..(line_number-2)].reverse.each do |l| break if l.gsub(/\s/,'').empty? c << l if l.match(/\A\s*\#/) end c.reverse.join("\n") end |