Class: Teodoro::ArquivoData::Valor

Inherits:
Object
  • Object
show all
Defined in:
lib/teodoro/arquivo_data.rb

Constant Summary collapse

FORMATADORES =
{
  bool: proc { _1 ? 'True' : 'False' },
  data: proc { "#{_1[-2..]}/#{_1[5..6]}/#{_1[0..3]}" if _1 },
  data_aaaammdd: proc { _1.delete('-') if _1 },
  mes_ano: proc { "#{_1[-2..]}/#{_1[0..3]}" if _1 }
}.freeze

Instance Method Summary collapse

Instance Method Details

#tipoObject



78
79
80
# File 'lib/teodoro/arquivo_data.rb', line 78

def tipo
  @tipo ||= arg[1] if arg.is_a?(Array)
end

#to_sObject



74
75
76
# File 'lib/teodoro/arquivo_data.rb', line 74

def to_s
  @to_s ||= (tipo ? FORMATADORES[tipo].call(valor) : valor).to_s
end

#valorObject



82
83
84
# File 'lib/teodoro/arquivo_data.rb', line 82

def valor
  @valor ||= arg.is_a?(Array) ? arg[0] : arg
end