Class: Main::Menu

Inherits:
Object
  • Object
show all
Defined in:
lib/ecraft-ow/menu.rb

Overview

clase principal del programa

Instance Method Summary collapse

Constructor Details

#initializeMenu

Returns a new instance of Menu.



11
12
13
14
15
16
17
18
19
20
# File 'lib/ecraft-ow/menu.rb', line 11

def initialize
  @opts = [
    { name: 'buscar una letra', value: 1 },
    { name: 'consultar clima', value: 2 },
    { name: 'salir', value: 3 }
  ]
  @continue = true
  @prompt = TTY::Prompt.new
  system 'clear'
end

Instance Method Details



48
49
50
51
52
53
54
# File 'lib/ecraft-ow/menu.rb', line 48

def menu_start
  while @continue == true
    mostrar_opciones
    @continue = @prompt.yes?('Desea continuar? ')
    system 'clear'
  end
end

#mostrar_opcionesObject



38
39
40
41
42
43
44
45
46
# File 'lib/ecraft-ow/menu.rb', line 38

def mostrar_opciones
  ops_selec = @prompt.select('que desea hacer? ', @opts, enum: ')')
  case ops_selec
  when 1 then selec_letra
  when 2 then selec_ciudad
  else
    exit
  end
end

#selec_ciudadObject



22
23
24
25
26
27
28
# File 'lib/ecraft-ow/menu.rb', line 22

def selec_ciudad
  ciudad = @prompt.ask('sobre que ciudad desea buscar?')
  hb = Request::HistoryBulk.new
  res = hb.by_city(ciudad)
  pdf = Document::Pdf.new
  pdf.create(res)
end

#selec_letraObject



30
31
32
33
34
35
36
# File 'lib/ecraft-ow/menu.rb', line 30

def selec_letra
  letra = @prompt.ask('que letra desea buscar?')
  pdf = Document::Pdf.new
  string = pdf.read
  counter = Cont::Char.new
  puts counter.count_char(string, letra)
end