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_aggregate ⇒ Object
.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_comparison(names_array) ⇒ Object
.country_comparison_full(names_array) ⇒ Object
.country_full(name) ⇒ Object
.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
|
.europe_aggregate ⇒ Object
.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
.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
.provinces(names) ⇒ Object
.south_america_aggregate ⇒ Object
.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
|