Class: SandiMeter::Calculator

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

Instance Method Summary collapse

Constructor Details

#initializeCalculator

Returns a new instance of Calculator.


3
4
5
6
# File 'lib/sandi_meter/calculator.rb', line 3

def initialize
  @data = {classes: [], methods: {}, method_calls: []}
  @output = {}
end

Instance Method Details

#calculate!(store_details = false) ⇒ Object


20
21
22
23
24
25
26
27
28
29
# File 'lib/sandi_meter/calculator.rb', line 20

def calculate!(store_details = false)
  @store_details = store_details

  check_first_rule
  check_second_rule
  check_third_rule
  check_fourth_rule

  @output
end

#push(data) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sandi_meter/calculator.rb', line 8

def push(data)
  data.each_pair do |key, value|
    if value.kind_of?(Array)
      @data[key] ||= []
      @data[key] += value
    elsif value.kind_of?(Hash)
      @data[key] ||= {}
      @data[key].merge!(value)
    end
  end
end