Class: Segurofacil::Estagiario

Inherits:
Object
  • Object
show all
Extended by:
REST::EstagiarioCreate, REST::EstagiarioRemove
Defined in:
lib/segurofacil/estagiario.rb

Constant Summary collapse

NAME =
'nome'
CPF =
'cPF'
BIRTHDATE =
'dOB'
GENDER =
'sexoId'
MALE =
1
FEMALE =
2

Constants included from REST::EstagiarioCreate

REST::EstagiarioCreate::PATH

Constants included from REST::EstagiarioRemove

REST::EstagiarioRemove::PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from REST::EstagiarioCreate

create

Methods included from REST::EstagiarioRemove

remove

Constructor Details

#initialize(options) ⇒ Estagiario

Returns a new instance of Estagiario.



17
18
19
20
21
22
# File 'lib/segurofacil/estagiario.rb', line 17

def initialize(options)
  @name      = options.fetch(NAME)
  @cpf       = options.fetch(CPF)
  @birthdate = options.fetch(BIRTHDATE)
  @gender    = options.fetch(GENDER)
end

Instance Attribute Details

#birthdateObject (readonly)

Returns the value of attribute birthdate.



15
16
17
# File 'lib/segurofacil/estagiario.rb', line 15

def birthdate
  @birthdate
end

#cpfObject (readonly)

Returns the value of attribute cpf.



15
16
17
# File 'lib/segurofacil/estagiario.rb', line 15

def cpf
  @cpf
end

#genderObject (readonly)

Returns the value of attribute gender.



15
16
17
# File 'lib/segurofacil/estagiario.rb', line 15

def gender
  @gender
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/segurofacil/estagiario.rb', line 15

def name
  @name
end

Class Method Details

.ary_to_estagiarios(list) ⇒ Object



52
53
54
55
# File 'lib/segurofacil/estagiario.rb', line 52

def ary_to_estagiarios(list)
  return [] if list.nil?
  list.map {|item| convert_to_estagiario(item) }
end

.convert_to_estagiario(hash) ⇒ Object



48
49
50
# File 'lib/segurofacil/estagiario.rb', line 48

def convert_to_estagiario(hash)
  self.new hash
end

.create(estagiario, cnpj) ⇒ Object



34
35
36
37
# File 'lib/segurofacil/estagiario.rb', line 34

def create(estagiario, cnpj)
  res = super estagiario, cnpj
  get_create_response(res)
end

.remove(estagiario_cpf, cnpj) ⇒ Object

Remove a estagiario from the policy

Parameters:

  • estagiario_cpf (String)

    the estagiario to be removed

  • cnpj (String)

    the cnpj of the company that holds the estagiario’s policy

Returns:

  • EstagiarioRemoveResponse



43
44
45
46
# File 'lib/segurofacil/estagiario.rb', line 43

def remove(estagiario_cpf, cnpj)
  res = super estagiario_cpf, cnpj
  get_remove_response(res)
end

Instance Method Details

#female?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/segurofacil/estagiario.rb', line 28

def female?
  gender == FEMALE
end

#male?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/segurofacil/estagiario.rb', line 24

def male?
  gender == MALE
end