momm 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/change_log.md +6 -0
- data/lib/momm/calculator.rb +9 -2
- data/lib/momm/version.rb +1 -1
- data/spec/momm/version_spec.rb +1 -1
- data/spec/momm/web_spec.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94e8df11708639f4efe46efce62df26f3828f893
|
4
|
+
data.tar.gz: 42b738fbed8e1abcf4fd9d230a75cf6068dda94a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cde56c7a6fe324b5e8e6998603a663a625e119cc6ca3858a482c62003702e3743aad5c1351e25878789711c6de359fb86f8e6d21c9fae3aa123b41850a7f8d07
|
7
|
+
data.tar.gz: 6b744408c973efa5246f98337ca9786da64f6646ce271493ffa9f2756d42d4a51049835f51f079c962b39437605719cc2f74b383f1afe2162ea70254c96f7385
|
data/change_log.md
ADDED
data/lib/momm/calculator.rb
CHANGED
@@ -50,6 +50,11 @@ module Momm
|
|
50
50
|
# the exchange rate
|
51
51
|
#
|
52
52
|
def exchange_rate(from, to, options = {})
|
53
|
+
origin_exchange_rate(from, to, options = {}).round(2)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Exchange Rate without precision bound
|
57
|
+
def origin_exchange_rate(from, to, options = {})
|
53
58
|
date = options[:date] || Date.today
|
54
59
|
date = Date.parse(date) if date.is_a? String
|
55
60
|
|
@@ -70,12 +75,14 @@ module Momm
|
|
70
75
|
set_rate(to, to_rate, date)
|
71
76
|
set_rate(from, from_rate, date)
|
72
77
|
|
73
|
-
return (to_rate / from_rate)
|
78
|
+
return (to_rate / from_rate)
|
74
79
|
end
|
75
80
|
|
76
81
|
0.0 / 0
|
77
82
|
end
|
78
83
|
|
84
|
+
private :origin_exchange_rate
|
85
|
+
|
79
86
|
# Exchange Money from one currency to another
|
80
87
|
#
|
81
88
|
# == Parameters
|
@@ -93,7 +100,7 @@ module Momm
|
|
93
100
|
#
|
94
101
|
def exchange(money, from, to, options= {})
|
95
102
|
options[:date] ||= Date.today
|
96
|
-
(
|
103
|
+
(origin_exchange_rate(from, to, options) * money).round(2)
|
97
104
|
end
|
98
105
|
|
99
106
|
# Delegate the get_rate method, if the target is missing
|
data/lib/momm/version.rb
CHANGED
data/spec/momm/version_spec.rb
CHANGED
data/spec/momm/web_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: momm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jingkai He
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- README.md
|
137
137
|
- Rakefile
|
138
138
|
- bin/momm
|
139
|
+
- change_log.md
|
139
140
|
- examples/rack_app/Gemfile
|
140
141
|
- examples/rack_app/config.ru
|
141
142
|
- examples/rails_app/.gitignore
|