paragoz 2.2.5 → 2.2.6

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: 2e257811bbc19b414706bc9085fee893ed001610
4
- data.tar.gz: 399fca4a2b9b936495b1c14800941589d11a4eee
3
+ metadata.gz: 629edb93d13bfb51bdb948a663075e7740331744
4
+ data.tar.gz: d7e930b81103001c07f512ca7a71f251a1464d2e
5
5
  SHA512:
6
- metadata.gz: 8bdd6feb4d7a1da1d1dce99fe4c3d178edfcfa54b26dac620d2f5b64acbc18194284542529f75b18b96657c12a32997acdc13c02ae638344c63839eea056a859
7
- data.tar.gz: 874b2948743ad67b304828258ae50a5afccaec9fb79c23e9abb6ac4ea8766dd0889a9e0829fbbb306cf15cdee7b164d3de773ab7abf827641317678c74acec72
6
+ metadata.gz: 1c85535c5215f66e65e1f3f8b3528d4efed3ae907db66efeb43e963da0d2fa2b0e448c274865dae40f29df744b55591badde12c0028193ce1f6a6e1dc7ff072c
7
+ data.tar.gz: 165ce1d8b513619b109bccef4157c2400e106786a10c5996b7e30669d81994c8d2e83d1da7eaa25078d45c866cbc8658743080c3ce0762396b5e627161e072f2
@@ -16,21 +16,21 @@ module Paragoz
16
16
 
17
17
  def initialize(code, amount, data, date)
18
18
  @data = data || parse_data(take_response(code.upcase, date))
19
- @time_array = @data["date"].split('-').map(&:to_i)
20
- @base = @data["base"]
21
- @date = @time_array && @time_array.is_a?(Array) ? Time.new(*@time_array) : Time.now
22
- @rates = @data["rates"]
23
- @costs = cost_of_other_currencies
24
- @amount = amount
19
+ @time_arr = @data["date"].split('-').map(&:to_i)
20
+ @base = @data["base"]
21
+ @date = @time_arr.is_a?(Array) ? Time.new(*@time_array) : Time.now
22
+ @rates = @data["rates"]
23
+ @costs = cost_of_other_currencies
24
+ @amount = amount
25
25
 
26
26
  @@currencies_defined += 1
27
27
  end
28
28
 
29
29
  def amount=(value)
30
- if value.is_a?(Numeric) && value.to_i > 0
31
- @amount = value.to_i
30
+ if value.to_f > 0.0
31
+ @amount = value.to_f
32
32
  else
33
- puts "ERROR! Amount must be a Number and greater than 0."
33
+ puts "ERROR! Amount must be a Number and greater than 0.0"
34
34
  end
35
35
  end
36
36
 
@@ -62,19 +62,21 @@ module Paragoz
62
62
 
63
63
  def calculate_cost(currency_code ,calculation_amount = 1.0, info = false)
64
64
  cost = 0.0
65
- if amount.is_a?(Numeric) && amount > 0 && CURRENCY_CODES.include?(currency_code.upcase)
65
+ if amount.to_f > 0.0 && CURRENCY_CODES.include?(currency_code.upcase)
66
66
  cost = self.costs[currency_code.upcase] * calculation_amount || self.amount
67
67
  puts "You need #{cost} #{@base} to buy #{amount} #{currency_code}" if info
68
68
  cost
69
69
  else
70
- puts "ERROR! You need to give 2 parameters >> currency_code & calculate_amount"
70
+ puts "ERROR! PARAMETERS ARE currency_code(string) & calculate_amount(float)"
71
+ puts "3rd parameter is boolean for extra info"
71
72
  end
72
73
  end
73
74
 
74
- def currency_to_currency(other_currency_object, info = false)
75
- if self.base != other_currency_object.base
76
- exchange = self.amount * self.rates[other_currency_object.base]
77
- printf("%.2f %s equals to %.4f %s \n", @amount, @base, exchange, other_currency_object.base) if info
75
+ def currency_to_currency(other_currency, info = false)
76
+ if self.base != other_currency.base
77
+ exchange = self.amount * self.rates[other_currency.base]
78
+ printf("%.2f %s equals to %.4f %s \n",
79
+ @amount, @base, exchange, other_currency.base) if info
78
80
  exchange
79
81
  else
80
82
  puts "Error! Trying to conver same currency object."
@@ -84,7 +86,8 @@ module Paragoz
84
86
 
85
87
  def exchange_to(currency_code, exchance_amount = nil, info = false)
86
88
  exchange = @rates[currency_code.upcase] * (exchance_amount || self.amount)
87
- printf("%.2f %s equals to %.4f", amount, @base, exchange) if info
89
+ printf("%.2f %s equals to %.4f",
90
+ amount, @base, exchange) if info
88
91
  exchange
89
92
  end
90
93
 
@@ -1,3 +1,3 @@
1
1
  module Paragoz
2
- VERSION = "2.2.5"
2
+ VERSION = "2.2.6"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paragoz
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gökhan Çağlar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-09 00:00:00.000000000 Z
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - bin/setup
94
94
  - lib/paragoz.rb
95
95
  - lib/paragoz/version.rb
96
+ - paragoz-2.2.5.gem
96
97
  - paragoz.gemspec
97
98
  homepage: https://github.com/cptangry/paragoz
98
99
  licenses: