foreign_currency_exchange 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f712145f1831ac7938c72551ea7573f15cc58098
4
- data.tar.gz: 981ba95ba055ce1523bdf4bda7a5fa4c48f75950
3
+ metadata.gz: 11fd1b7993283a906151242c99dca97902585b18
4
+ data.tar.gz: 6ba6f7884446f3490237d6a4a7298270a8aadcbf
5
5
  SHA512:
6
- metadata.gz: 5d3b01d2b81041af0db49cb6f65ab90e20d990e9776b4b365c562f8aa2e0bbcd2ce9de09fd89c1fed3fd55ae259896f80cb3de5619e21419f285e6631895eedb
7
- data.tar.gz: 9ac7c85f292e5335929dd2046a655efe7da2915cb1f64dfc9ed480bf8d1bac5e1c8c26e6f7463743dc7ffd0e5d838a67974bddd0617d660974ad8f91476d55b2
6
+ metadata.gz: e1c239dc8fd0bee0ec3d95774ef79096b2add4b6139cab693fa2a67728f6af7264cd07a2a31227737deb0e916c56971c3651d0e8159f4fc876033f29eeac3d96
7
+ data.tar.gz: a99b889d14a81e49c13a16da7f84b81ba59d24c3b16a2120bd2b3077e83eb60938d0c4cc97371324643e2829be72dcf1a1618393e334aea1f7f6a9bd175fa249
@@ -17,7 +17,7 @@ module ForeignCurrencyExchange
17
17
  def initialize(amount, currency)
18
18
  check_configuration # Configuration should be valid.
19
19
  check_currency(currency) # Currency should be configured before.
20
- @amount = amount.is_a?(Integer) ? amount : amount.to_f.round(ROUND_LEVEL)
20
+ @amount = prepare_amount(amount)
21
21
  @currency = currency
22
22
  end
23
23
 
@@ -25,7 +25,7 @@ module ForeignCurrencyExchange
25
25
  # or converted current object amount to base_currency otherwise.
26
26
  def base_amount
27
27
  return amount if currency == base_currency
28
- (amount / rates[currency].to_f).round(ROUND_LEVEL)
28
+ prepare_amount(amount / rates[currency].to_f)
29
29
  end
30
30
 
31
31
  def <=>(other)
@@ -72,8 +72,12 @@ module ForeignCurrencyExchange
72
72
 
73
73
  private
74
74
 
75
+ def prepare_amount(amount)
76
+ amount.integer? ? amount : amount.round(ROUND_LEVEL)
77
+ end
78
+
75
79
  def formatted_amount
76
- amount.is_a?(Integer) ? amount.to_s : format(AMOUNT_FORMAT, amount)
80
+ amount.integer? ? amount.to_s : format(AMOUNT_FORMAT, amount)
77
81
  end
78
82
 
79
83
  # Returns amount based on given currency,
@@ -1,3 +1,3 @@
1
1
  module ForeignCurrencyExchange
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_currency_exchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Lynda