Class: Turbulence::Calculators::Complexity
- Inherits:
-
Object
- Object
- Turbulence::Calculators::Complexity
- Defined in:
- lib/turbulence/calculators/complexity.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #flogger ⇒ Object
- #for_these_files(files) ⇒ Object
-
#initialize(config = nil) ⇒ Complexity
constructor
A new instance of Complexity.
- #score_for_file(filename) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Complexity
Returns a new instance of Complexity.
22 23 24 |
# File 'lib/turbulence/calculators/complexity.rb', line 22 def initialize(config = nil) @config = config || Turbulence.config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/turbulence/calculators/complexity.rb', line 21 def config @config end |
Instance Method Details
#flogger ⇒ Object
26 27 28 |
# File 'lib/turbulence/calculators/complexity.rb', line 26 def flogger @flogger ||= Flog19.new(:continue => true) end |
#for_these_files(files) ⇒ Object
30 31 32 33 34 |
# File 'lib/turbulence/calculators/complexity.rb', line 30 def for_these_files(files) files.each do |filename| yield filename, score_for_file(filename) end end |
#score_for_file(filename) ⇒ Object
36 37 38 39 40 |
# File 'lib/turbulence/calculators/complexity.rb', line 36 def score_for_file(filename) flogger.reset flogger.flog filename flogger.total_score end |