Class: Covid19::Client

Inherits:
Thor
  • Object
show all
Defined in:
lib/covid19/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/covid19/client.rb', line 8

def self.exit_on_failure?
  true
end

Instance Method Details

#all_continentsObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/covid19/client.rb', line 16

def all_continents
  locality  = Covid19::Decorators::Table::LOCALITY[:continent]
  result = Covid19::Services::Covid19Data.all_continents

  puts result if options.empty?
  render_table(data: result, locality: locality) if options[:table]
  render_chart(data: result,
               type: Covid19::Decorators::Chart::TYPES[:all_continent_general_data],
               colored: options[:colored]) if options[:chart]
end

#all_countriesObject



29
30
31
32
33
34
35
# File 'lib/covid19/client.rb', line 29

def all_countries
  locality  = Covid19::Decorators::Table::LOCALITY[:country]
  result = Covid19::Services::Covid19Data.all_countries
  
  puts result if options.empty?
  render_table(data: result, locality: locality) if options[:table]
end

#continent(continent_name) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/covid19/client.rb', line 41

def continent(continent_name)
  result = Covid19::Services::Covid19Data.continent(continent_name)

  puts result if options.empty?
  render_table(data: result) if options[:table]
  
  if options[:chart]
    render_chart(data: result,
                 type: Covid19::Decorators::Chart::TYPES[:continent_general_data],
                 colored: options[:colored])
    render_chart(data: result,
                 type: Covid19::Decorators::Chart::TYPES[:continent_diary_data],
                 colored: options[:colored])
  end
end

#country(country_name) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/covid19/client.rb', line 62

def country(country_name)
  result = Covid19::Services::Covid19Data.country(country_name)

  puts result if options.empty?
  
  render_table(data: result) if options[:table]
  
  if options[:chart]
    render_chart(data: result,
                 type: Covid19::Decorators::Chart::TYPES[:country_general_data],
                 colored: options[:colored])
    render_chart(data: result,
                 type: Covid19::Decorators::Chart::TYPES[:country_diary_data],
                 colored: options[:colored])
  end
end