Method: WAS::Score#calculate

Defined in:
lib/was/score.rb

#calculate(option = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/was/score.rb', line 43

def calculate(option = nil)
  return calculation if option != :tree

  calc = calculation(:tree)
  tree = if calc.is_a?(Hash)
    calc.merge(additional_score_attributes(calc[:score]))
  else
    {}.tap do |t|
      t.merge!(score: calc)
      t.merge!(additional_score_attributes(calc))
    end
  end

  transform_scores_relative_to_max_score(tree)
end