ea_currency_converter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ea_currency_converter.rb +26 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0f809e2dd301c4c27dfe59b80282e1a2d4c5b4e20d39dbfeb5fff2379c9d4eaa
|
|
4
|
+
data.tar.gz: ad1897882aedc9d2e5670761f54c8ae4a2c577459e48cc42a254c2cc7e94b0a0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f9b9cee11bc87981f86f6fba210e3ec15375bde330576a84e65ce4340794b9cb9c95cc595d0ebabc7a9795fb8806317afdb81f4f2dd38060f2d899c9a3c8efe4
|
|
7
|
+
data.tar.gz: 78bfd848044e15c6fcd4fdbbc2097fc324dd377b63685a53b7c02b7c44c5c402509948d8d16a04e6b541c3993d1bcec9b5b85cf9e938a4689dd91d4498d90159
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module EACurrencyConverter
|
|
2
|
+
class Converter
|
|
3
|
+
# Hardcoded exchange rates relative to USD
|
|
4
|
+
EXCHANGE_RATES = {
|
|
5
|
+
'USD' => 1.0, # US Dollar
|
|
6
|
+
'KES' => 115.0, # Kenyan Shilling
|
|
7
|
+
'UGX' => 3700.0, # Ugandan Shilling
|
|
8
|
+
'TZS' => 2300.0, # Tanzanian Shilling
|
|
9
|
+
'RWF' => 1150.0, # Rwandan Franc
|
|
10
|
+
'BIF' => 2100.0 # Burundian Franc
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
# Converts an amount from one currency to another
|
|
14
|
+
def self.convert(amount, from_currency, to_currency)
|
|
15
|
+
from_rate = EXCHANGE_RATES[from_currency]
|
|
16
|
+
to_rate = EXCHANGE_RATES[to_currency]
|
|
17
|
+
|
|
18
|
+
raise ArgumentError, "Unsupported currency: #{from_currency}" unless from_rate
|
|
19
|
+
raise ArgumentError, "Unsupported currency: #{to_currency}" unless to_rate
|
|
20
|
+
|
|
21
|
+
# Convert to USD first, then to the target currency
|
|
22
|
+
usd_amount = amount / from_rate
|
|
23
|
+
(usd_amount * to_rate).round(2)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ea_currency_converter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- XessiveObserver
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: If your in need of an easy to use gem to assist in currency conversion
|
|
14
|
+
email: xessiveobserver@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/ea_currency_converter.rb
|
|
20
|
+
homepage: https://rubygems.org/gems/ea_currency_converter
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata:
|
|
24
|
+
source_code_uri: https://github.com/XessiveObserver/ea_currency_converter
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.5.22
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Easeas currency conversion in East Africa
|
|
44
|
+
test_files: []
|