lariconv 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/lariconv.rb +18 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a90d47353f67337f935248d3fbaf1ae461c9783b1061c2ad518b05043779bf8
|
4
|
+
data.tar.gz: ba924d182e982e68d5c4db84e19faeec7de2487e0e50ad0e6b78796a2d4c8a04
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d7e2f5837856d4070b6b451cb811b08955639b1b41c34275b373ce4e6f05b65b7f614cffa7bdb884433b7756dac970a27053ef499f73757919b9e18018bf543
|
7
|
+
data.tar.gz: 1f597a15f4a1e6e3476b17e9e525e31629c6d37223dc10ebb11136fd676dd85be7c866be86a760b3f5e129169f9569f3132e7ec46b95cbfc201b7dd13e678279
|
data/lib/lariconv.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
URL = 'https://nbg.gov.ge/gw/api/ct/monetarypolicy/currencies/en/json'
|
7
|
+
|
8
|
+
class Lariconv
|
9
|
+
def self.convert(amount, currency, date)
|
10
|
+
url = "#{URL}?currencies=#{currency}&date=#{date}"
|
11
|
+
response = JSON.parse(URI.parse(url).read)
|
12
|
+
data = response.first['currencies'].first
|
13
|
+
quantity = data['quantity']
|
14
|
+
rate = data['rate']
|
15
|
+
result = amount.to_f / quantity * rate
|
16
|
+
result.round(2)
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lariconv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Den Patin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2
|
14
|
+
`lariconv` is a gem that converts different currencies to Georgian Lari
|
15
|
+
based on the National Bank of Georgia's exchange rate for a given date.
|
16
|
+
email: den@hey.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/lariconv.rb
|
22
|
+
homepage: https://github.com/denpatin/lariconv
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata:
|
26
|
+
rubygems_mfa_required: 'true'
|
27
|
+
source_code_uri: https://github.com/denpatin/lariconv
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.0.0
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubygems_version: 3.4.18
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: World currencies to Georgian Lari converter
|
47
|
+
test_files: []
|