lbank 0.0.1 → 0.0.2
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/.travis.yml +7 -0
- data/Gemfile +2 -1
- data/README.md +2 -0
- data/Rakefile +5 -0
- data/lib/lbank.rb +3 -1
- data/lib/lbank/version.rb +1 -1
- data/spec/lbank_spec.rb +10 -4
- metadata +2 -1
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/lbank.rb
CHANGED
@@ -15,7 +15,9 @@ module Lbank
|
|
15
15
|
url = "#{SOURCE}?Y=%i&M=%i&D=%i&S=csv" % [ date.year, date.month, date.day ]
|
16
16
|
rates = {}
|
17
17
|
|
18
|
-
|
18
|
+
data = open(url).read
|
19
|
+
|
20
|
+
CSV.parse(data).each do |row|
|
19
21
|
rates[row[1]] = row[2].to_i / row[3].to_f
|
20
22
|
end
|
21
23
|
|
data/lib/lbank/version.rb
CHANGED
data/spec/lbank_spec.rb
CHANGED
@@ -13,10 +13,16 @@ describe Lbank do
|
|
13
13
|
|
14
14
|
date = Date.new(2012, 8, 4)
|
15
15
|
|
16
|
-
subject.convert_currency(10, 'LTL', 'EUR', date)
|
17
|
-
subject.convert_currency(10, 'LTL', 'USD', date)
|
18
|
-
subject.convert_currency(100, 'RUB', 'LTL', date)
|
19
|
-
subject.convert_currency(100, 'RUB', 'USD', date)
|
16
|
+
round(subject.convert_currency(10, 'LTL', 'EUR', date)).should == 2.90
|
17
|
+
round(subject.convert_currency(10, 'LTL', 'USD', date)).should == 3.55
|
18
|
+
round(subject.convert_currency(100, 'RUB', 'LTL', date)).should == 8.68
|
19
|
+
round(subject.convert_currency(100, 'RUB', 'USD', date)).should == 3.08
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def round(number, precision = 2)
|
25
|
+
("%.#{precision}f" % number).to_f
|
20
26
|
end
|
21
27
|
|
22
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- .gitignore
|
22
22
|
- .rspec
|
23
|
+
- .travis.yml
|
23
24
|
- Gemfile
|
24
25
|
- LICENSE
|
25
26
|
- README.md
|