Module: Meteoservice::TownsData

Extended by:
Constants, NestedHashValue, ParserXml
Defined in:
lib/meteoservice/towns_data.rb

Constant Summary

Constants included from Constants

Constants::BASE_URL, Constants::CLOUDINESS, Constants::DAYS_OF_WEEK, Constants::KEYS_DATA, Constants::KEYS_LIMIT, Constants::KEYS_PHENOMENA, Constants::PRECIPITATION, Constants::RPOWER, Constants::SPOWER, Constants::WIND_DIRECTION

Class Method Summary collapse

Methods included from NestedHashValue

nested_hash_value

Methods included from ParserXml

connection

Class Method Details

.auto_process(city_index) ⇒ Object



33
34
35
36
37
# File 'lib/meteoservice/towns_data.rb', line 33

def auto_process(city_index)
  path = "/export/gismeteo/point/#{city_index}.xml"

  data_taking(path, city_index)
end

.processObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/meteoservice/towns_data.rb', line 10

def process
  catalogue = load

  puts <<~TOWNS
    \nПогоду для какого города Вы хотите узнать?
    Введите уникальный индекс города и нажмите "enter". Если вашего города#{' '}
    нет в списке, перейдите по ссылке https://www.meteoservice.ru/content/export.html,
    найдите интересуемый индекс и введите его ниже. Название города с индексом добавятся
    в список автоматически:\n
  TOWNS

  catalogue.sort_by { |_key, value| value }
           .to_h.each_with_index { |name, index| puts "#{index + 1}: #{name}" }

  city_index = gets.to_i
  path = "/export/gismeteo/point/#{city_index}.xml"
  if catalogue.key?('city_index')
    data_taking(path, city_index)
  else
    data_taking(path, city_index, catalogue, conservation: true)
  end
end