Module: Kovid

Defined in:
lib/kovid/ascii_charts.rb,
lib/kovid.rb,
lib/kovid/cli.rb,
lib/kovid/cache.rb,
lib/kovid/helpers.rb,
lib/kovid/request.rb,
lib/kovid/version.rb,
lib/kovid/constants.rb,
lib/kovid/tablelize.rb,
lib/kovid/historians.rb,
lib/kovid/aggregators.rb,
lib/kovid/uri_builder.rb

Overview

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Aggregators, AsciiCharts, Constants, Historians Classes: CLI, Cache, Request, Tablelize, UriBuilder

Constant Summary collapse

VERSION =
'0.7.1'

Class Method Summary collapse

Class Method Details

.add_plus_sign(num) ⇒ Object

Insert + sign to format positive numbers



24
25
26
# File 'lib/kovid/helpers.rb', line 24

def add_plus_sign(num)
  num.to_i.positive? ? "+#{comma_delimit(num)}" : comma_delimit(num).to_s
end

.africa_aggregateObject



19
20
21
# File 'lib/kovid.rb', line 19

def africa_aggregate
  Kovid::Request.africa_aggregate
end

.all_us_statesObject



55
56
57
# File 'lib/kovid.rb', line 55

def all_us_states
  Kovid::Request.all_us_states
end

.asia_aggregateObject



27
28
29
# File 'lib/kovid.rb', line 27

def asia_aggregate
  Kovid::Request.asia_aggregate
end

.casesObject



67
68
69
# File 'lib/kovid.rb', line 67

def cases
  Kovid::Request.cases
end

.comma_delimit(number) ⇒ Object



19
20
21
# File 'lib/kovid/helpers.rb', line 19

def comma_delimit(number)
  number.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(',').reverse
end

.country(name) ⇒ Object



31
32
33
# File 'lib/kovid.rb', line 31

def country(name)
  Kovid::Request.by_country(name)
end

.country_comparison(names_array) ⇒ Object



59
60
61
# File 'lib/kovid.rb', line 59

def country_comparison(names_array)
  Kovid::Request.by_country_comparison(names_array)
end

.country_comparison_full(names_array) ⇒ Object



63
64
65
# File 'lib/kovid.rb', line 63

def country_comparison_full(names_array)
  Kovid::Request.by_country_comparison_full(names_array)
end

.country_full(name) ⇒ Object



35
36
37
# File 'lib/kovid.rb', line 35

def country_full(name)
  Kovid::Request.by_country_full(name)
end

.dateman(date) ⇒ Object

Parse date as “02 Apr, 20”



14
15
16
17
# File 'lib/kovid/helpers.rb', line 14

def dateman(date)
  date_to_parse = Date.strptime(date, '%m/%d/%y').to_s
  Date.parse(date_to_parse).strftime('%d %b, %y')
end

.eu_aggregateObject



11
12
13
# File 'lib/kovid.rb', line 11

def eu_aggregate
  Kovid::Request.eu_aggregate
end

.europe_aggregateObject



15
16
17
# File 'lib/kovid.rb', line 15

def europe_aggregate
  Kovid::Request.europe_aggregate
end

.histogram(country, date) ⇒ Object



79
80
81
# File 'lib/kovid.rb', line 79

def histogram(country, date)
  Kovid::Request.histogram(country, date)
end

.history(country, days = 30) ⇒ Object



71
72
73
# File 'lib/kovid.rb', line 71

def history(country, days = 30)
  Kovid::Request.history(country, days)
end

.history_us_state(state, days = 30) ⇒ Object



75
76
77
# File 'lib/kovid.rb', line 75

def history_us_state(state, days = 30)
  Kovid::Request.history_us_state(state, days)
end

.info_table(message) ⇒ Object



8
9
10
11
# File 'lib/kovid/helpers.rb', line 8

def info_table(message)
  rows = [[message.to_s]]
  puts Terminal::Table.new title: '❗️', rows: rows
end

.lookup_us_state(state) ⇒ Object



28
29
30
# File 'lib/kovid/helpers.rb', line 28

def lookup_us_state(state)
  Kovid::Constants::USA_ABBREVIATIONS.fetch(state.downcase, state)
end

.province(name) ⇒ Object



39
40
41
# File 'lib/kovid.rb', line 39

def province(name)
  Kovid::Request.province(name)
end

.provinces(names) ⇒ Object



43
44
45
# File 'lib/kovid.rb', line 43

def provinces(names)
  Kovid::Request.provinces(names)
end

.south_america_aggregateObject



23
24
25
# File 'lib/kovid.rb', line 23

def south_america_aggregate
  Kovid::Request.south_america_aggregate
end

.state(state) ⇒ Object



47
48
49
# File 'lib/kovid.rb', line 47

def state(state)
  Kovid::Request.state(state)
end

.states(states) ⇒ Object



51
52
53
# File 'lib/kovid.rb', line 51

def states(states)
  Kovid::Request.states(states)
end

.top(count, options = { location: :countries, incident: :cases }) ⇒ Object



83
84
85
# File 'lib/kovid.rb', line 83

def top(count, options = { location: :countries, incident: :cases })
  Kovid::Request.top(count, options)
end