no_nonsense_currency_converter 0.0.2 → 0.0.3
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.
- data/Gemfile.lock +1 -1
- data/README.md +15 -1
- data/lib/no_nonsense_currency_converter.rb +9 -3
- data/lib/no_nonsense_currency_converter/version.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
No Nonsense Currency Converter
|
|
2
2
|
==============================
|
|
3
|
+
A crude currency converter based on the Google Finance API - WIP, no tests. Still very Alpha
|
|
4
|
+
|
|
5
|
+
Usage
|
|
6
|
+
-----
|
|
7
|
+
```ruby
|
|
8
|
+
NoNonsenseCurrencyConverter.get_converted_currency_value(from, to, amount)
|
|
9
|
+
```
|
|
10
|
+
Example:
|
|
11
|
+
```ruby
|
|
12
|
+
> NoNonsenseCurrencyConverter.get_converted_currency_value('USD', 'GBP', 10)
|
|
13
|
+
=> 5.93
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Please report any issues and I will fix them as soon as possible.
|
|
@@ -5,9 +5,15 @@ module NoNonsenseCurrencyConverter
|
|
|
5
5
|
BASE_URL = 'https://www.google.com/'
|
|
6
6
|
CONVERTER_URL = 'finance/converter'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
@@rate_hash = {}
|
|
9
|
+
|
|
10
|
+
def self.get_converted_currency_value(from_currency, to_currency, amount)
|
|
11
|
+
unless @@rate_hash[from_currency].try(:[], to_currency).try(:[], amount).present?
|
|
12
|
+
data = get_raw_data(amount, from_currency, to_currency)
|
|
13
|
+
converted_amount = get_final_parsed_amount(data).to_f.round(2)
|
|
14
|
+
@@rate_hash.merge!(from_currency => { to_currency => { amount => converted_amount } })
|
|
15
|
+
end
|
|
16
|
+
@@rate_hash[from_currency][to_currency][amount]
|
|
11
17
|
end
|
|
12
18
|
|
|
13
19
|
private
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: no_nonsense_currency_converter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
74
74
|
version: '0'
|
|
75
75
|
segments:
|
|
76
76
|
- 0
|
|
77
|
-
hash:
|
|
77
|
+
hash: 2932767722201697778
|
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
none: false
|
|
80
80
|
requirements:
|
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
83
|
version: '0'
|
|
84
84
|
segments:
|
|
85
85
|
- 0
|
|
86
|
-
hash:
|
|
86
|
+
hash: 2932767722201697778
|
|
87
87
|
requirements: []
|
|
88
88
|
rubyforge_project:
|
|
89
89
|
rubygems_version: 1.8.23
|