Class: SandiMeter::RulesChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/sandi_meter/rules_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(data, config) ⇒ RulesChecker

Returns a new instance of RulesChecker.


3
4
5
6
7
8
9
10
# File 'lib/sandi_meter/rules_checker.rb', line 3

def initialize(data, config)
  @config = config
  @rules = []
  @rules << percentage(data[:first_rule][:small_classes_amount], data[:first_rule][:total_classes_amount])
  @rules << percentage(data[:second_rule][:small_methods_amount], data[:second_rule][:total_methods_amount])
  @rules << percentage(data[:third_rule][:proper_method_calls], data[:third_rule][:total_method_calls])
  @rules << percentage(data[:fourth_rule][:proper_controllers_amount], data[:fourth_rule][:total_controllers_amount])
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/sandi_meter/rules_checker.rb', line 12

def ok?
  @rules.reduce(:+) / 4 > @config[:threshold]
end