Completed
Push — master ( ad3537...3da399 )
by Borja
03:54
created

Profesion.imped()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
ccs 1
cts 2
cp 0.5
crap 1.125
rs 10
c 0
b 0
f 0
1
# Clase para gestionar las profesiones y sus grados.
2
# TODO necesita refactor segun la nueva forma de organizar los datos
3 1
class Profesion < Hash
4 1
  attr_accessor :id, :name, :aprendiz, :artesano, :maestro
5
6 1
  def initialize(args)
7
    args.each do |k, v|
8
      instance_variable_set("@#{k}".to_sym, v) unless v.nil?
9
    end
10
  end
11
12 1
  def img_path
13
    "'../../images/profesiones/#{name}.png'"
14
  end
15
16 1
  def aprendizajes
17
    profesion(id)['aprendiz']
18
  end
19
20 1
  def artesanias
21
    profesion(id)['artesano']
22
  end
23
24 1
  def maestrias
25
    profesion(id)['maestro']
26
  end
27
  
28 1
  def imped
29
    %w(clérigo bárbaro elfo mago enano 
30
    tiefling rakshasa ladrón elohim)[id]
31
  end
32
  
33 1
  def why
0 ignored issues
show
Coding Style introduced by
The method why seems to be too complex. Perceived cyclomatic complexity is 10 with a maxiumum of 6 permitted.
Loading history...
Coding Style introduced by
This method is 11 lines long. Your coding style permits a maximum length of 10.
Loading history...
34
    case imped
35
    when 'clérigo'  then 'Las artes Oscuras de la alquimia son heréticas'
36
    when 'bárbaro'  then 'Los bárbaros son analfabetos'
37
    when 'elfo'     then 'El cadáver de una bestia debe ser respetado'
38
    when 'mago'     then 'La mejor táctica suele ser quemarlo todo'
39
    when 'enano'    then 'Los encantamientos son deshonorables para la guerra'
40
    when 'tiefling' then 'Prefieren alejarse de la plata, en la medida lo posible'
0 ignored issues
show
Coding Style introduced by
This line is 82 characters long. Your coding style permits a maximum length of 80
Loading history...
41
    when 'rakshasa' then 'La madera es un material escaso en los lejanos desiertos del león'
0 ignored issues
show
Coding Style introduced by
This line is 92 characters long. Your coding style permits a maximum length of 80
Loading history...
42
    when 'ladrón'   then 'Se niegan a hacer horas extra, y tienen un código de honor.'
0 ignored issues
show
Coding Style introduced by
This line is 86 characters long. Your coding style permits a maximum length of 80
Loading history...
43
    when 'elohim'   then 'Según sus preceptos de fe, las aves son libres de toda servidumbre'
0 ignored issues
show
Coding Style introduced by
This line is 93 characters long. Your coding style permits a maximum length of 80
Loading history...
44
    end
45
  end
46
  
47
end
48