Class: Steep::Services::StatsCalculator
- Defined in:
- lib/steep/services/stats_calculator.rb
Defined Under Namespace
Classes: ErrorStats, SuccessStats
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #calc_stats(target, file:) ⇒ Object
-
#initialize(service:) ⇒ StatsCalculator
constructor
A new instance of StatsCalculator.
- #project ⇒ Object
Constructor Details
#initialize(service:) ⇒ StatsCalculator
Returns a new instance of StatsCalculator.
29 30 31 |
# File 'lib/steep/services/stats_calculator.rb', line 29 def initialize(service:) @service = service end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
27 28 29 |
# File 'lib/steep/services/stats_calculator.rb', line 27 def service @service end |
Instance Method Details
#calc_stats(target, file:) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/steep/services/stats_calculator.rb', line 37 def calc_stats(target, file:) if typing = file.typing typed = 0 untyped = 0 errors = 0 typing.method_calls.each_value do |call| case call when TypeInference::MethodCall::Typed typed += 1 when TypeInference::MethodCall::Untyped untyped += 1 when TypeInference::MethodCall::Error, TypeInference::MethodCall::NoMethodError errors += 1 else raise end end SuccessStats.new( target: target, path: file.path, typed_calls_count: typed, untyped_calls_count: untyped, error_calls_count: errors ) else ErrorStats.new(target: target, path: file.path) end end |
#project ⇒ Object
33 34 35 |
# File 'lib/steep/services/stats_calculator.rb', line 33 def project service.project end |