Class: Formatafacil::TarefaChooser

Inherits:
Object
  • Object
show all
Defined in:
lib/formatafacil/tarefa_chooser.rb

Instance Method Summary collapse

Instance Method Details

#escolhe_tarefaObject



19
20
21
22
23
24
25
26
27
# File 'lib/formatafacil/tarefa_chooser.rb', line 19

def escolhe_tarefa
  Formatafacil::TarefaModelos.new().modelos_disponiveis.each do |modelo|
    if existe_arquivo_de_texto?(markdown_file(modelo)) then
      return Formatafacil::ArtigoTarefa.new(modelo: modelo)
    else
      raise ArquivoDeTextoNaoEncontradoException
    end
  end
end

#existe_arquivo_de_texto?(arquivo) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/formatafacil/tarefa_chooser.rb', line 33

def existe_arquivo_de_texto?(arquivo)
  File.exist?(arquivo)
end

#markdown_file(file) ⇒ Object



29
30
31
# File 'lib/formatafacil/tarefa_chooser.rb', line 29

def markdown_file(file)
  "#{file}.md"
end