Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 23.81% |
Changes | 0 |
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 |
|
|
|||
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 |