Class: FiltrosPersonalizados::FieldsPadroes::Idade
- Inherits:
-
Field
- Object
- Field
- FiltrosPersonalizados::FieldsPadroes::Idade
show all
- Defined in:
- lib/filtros_personalizados/fields_padroes/idade.rb
Constant Summary
Constants inherited
from Field
Field::DIFERENTE, Field::ENTRE, Field::IGUAL, Field::MAIOR_QUE, Field::MENOR_QUE, Field::NENHUM, Field::TODOS
Instance Attribute Summary
Attributes inherited from Field
#association, #autocomplete_path, #collection, #collection_id, #collection_name, #field_name, #field_type, #is_open, #noactions, #options, #partial_name, #relation, #tipo_selecionado, #values
Instance Method Summary
collapse
Methods inherited from Field
#caption, #initialize
Instance Method Details
#acoes_disponiveis ⇒ Object
5
6
7
|
# File 'lib/filtros_personalizados/fields_padroes/idade.rb', line 5
def acoes_disponiveis
["Igual a", "Diferente de", "Entre", "Nenhum", "Todos"]
end
|
#file ⇒ Object
21
22
23
|
# File 'lib/filtros_personalizados/fields_padroes/idade.rb', line 21
def file
'personalizaveis/integer'
end
|
#selecao ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/filtros_personalizados/fields_padroes/idade.rb', line 25
def selecao
self.values.present? ? "selecao Idade " : ""
if self.values.present?
case self.tipo_selecionado
when "Igual a" then "Idade: #{values.first} anos"
when "Diferente de" then "Idade: diferente de #{values.first} anos"
when "Entre" then "Idade: #{values.first} até #{values.last} anos"
else ""
end
end
end
|
#where ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/filtros_personalizados/fields_padroes/idade.rb', line 9
def where
return "" if values.blank?
case self.tipo_selecionado
when "Igual a" then "idade_a(pacientes.data_nascimento, interns.data_entrada) == #{values.first}"
when "Diferente de" then "idade_a(pacientes.data_nascimento, interns.data_entrada) <> #{values.first}"
when "Entre" then "idade_a(pacientes.data_nascimento, interns.data_entrada) between #{values.first} and #{values.last}"
when "Nenhum" then "idade_a(pacientes.data_nascimento, interns.data_entrada) isnull "
when "Todos" then "idade_a(pacientes.data_nascimento, interns.data_entrada) notnull "
else ""
end
end
|