Class: Exercism::Analyzers::Shebang

Inherits:
Analyzer
  • Object
show all
Defined in:
lib/exercism-analysis/analyzers/ruby/shebang.rb

Instance Attribute Summary

Attributes inherited from Analyzer

#adapter, #processor

Instance Method Summary collapse

Methods inherited from Analyzer

#initialize, #lines, #padding, processor, #with_tempfile

Constructor Details

This class inherits a constructor from Exercism::Analyzers::Analyzer

Instance Method Details

#callObject



6
7
8
# File 'lib/exercism-analysis/analyzers/ruby/shebang.rb', line 6

def call
  Result.new(:shebang, feedback)
end

#feedbackObject



10
11
12
13
14
# File 'lib/exercism-analysis/analyzers/ruby/shebang.rb', line 10

def feedback
  shebang.map do |(line, line_no)|
    Feedback.from_line(:shebang, line.chomp, line_no)
  end
end

#shebangObject



16
17
18
# File 'lib/exercism-analysis/analyzers/ruby/shebang.rb', line 16

def shebang
  adapter.code.lines.zip(1..Float::INFINITY).select { |(l, _)| l.start_with?('#!') }.take(1)
end