Material   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 23.81%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 5
cts 21
cp 0.2381
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A usado_en() 0 13 1
A description() 0 3 1
A disponibles() 0 10 1
1
# Materiales necesarios para las profesiones
2 1
class Material < Util
3 1
  def name
4
    material(id)['name']
5
  end
6
7 1
  def description
8
    material(id)['description']
9
  end
10
11
  # returns from heros.materiales, the list of (maybe repeated)
12
  # ids of the heros with self.id material available
13 1
  def disponibles
14
    total = []
15
    heros.each do |h|
16
      next unless h.materiales
17
      h.materiales.each do |matt|
18
        total << h.id if matt == id
19
      end
20
    end
21
    total
22
  end
23
24 1
  def usado_en
0 ignored issues
show
Coding Style introduced by
This method is 11 lines long. Your coding style permits a maximum length of 10.
Loading history...
25
    usado = []
26
    profesions.each do |prof|
27
      %w(aprendiz artesano maestro).each do |grado|
28
        prof.send(grado).each do |receta|
29
          next unless receta['matts']
30
          next unless receta['matts'].include?(id)
31
          usado << { prof: id, grado: grado, receta: receta }
32
        end
33
      end
34
    end
35
    usado
36
  end
37
end
38