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.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
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.
9 10 11 12 |
# File 'lib/turbulence/calculators/complexity.rb', line 9 def initialize(config = nil) @config = config || Turbulence.config @type = :complexity end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/turbulence/calculators/complexity.rb', line 7 def config @config end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/turbulence/calculators/complexity.rb', line 7 def type @type end |
Instance Method Details
#flogger ⇒ Object
14 15 16 |
# File 'lib/turbulence/calculators/complexity.rb', line 14 def flogger @flogger ||= Flog.new(continue: true) end |
#for_these_files(files) ⇒ Object
18 19 20 21 22 |
# File 'lib/turbulence/calculators/complexity.rb', line 18 def for_these_files(files) files.each do |filename| yield filename, score_for_file(filename) end end |
#score_for_file(filename) ⇒ Object
24 25 26 27 28 |
# File 'lib/turbulence/calculators/complexity.rb', line 24 def score_for_file(filename) flogger.reset flogger.flog filename flogger.total_score end |