convertify 0.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/convertify.rb +17 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35abbfa6fcff6834827d4761424c038e9ba6f46a
4
+ data.tar.gz: 3afcc18909f4b4c2ef9dd538a40701e60e93763e
5
+ SHA512:
6
+ metadata.gz: beafea62c3a5b97a54d6876b93179385dbd6e107a713ab8f9a3716e56502d5d2ed3dd65755081c6b5bcb1b215331883a442b8504184e396a1c8a976e420196a4
7
+ data.tar.gz: 06d7d13b344d7b8c3865598a65f86979da06f43e348271b70450f5c0dc2d054aec2ef9224ffd41ba4c6a5805a158567fa27b793decb8a9e8203fa82c22a8b061
@@ -0,0 +1,17 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module Convertify
6
+ def convert(amount, current, convert_to)
7
+ url = URI('http://data.fixer.io/api/latest?access_key=77622eb94ba284531ea444fa6b591419&symbols=USD, CAD, AUD, PLN, MXN')
8
+ response = Net::HTTP.get(url)
9
+ response = JSON.parse(response)
10
+ amount * response["rates"][convert_to] / response["rates"][current]
11
+ end
12
+
13
+ def format(num)
14
+ "$#{num.round(2)}"
15
+ end
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: convertify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Niko Kouloufakos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple currency conversion gem
14
+ email: nikolas.kouloufakos@shopify.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/convertify.rb
20
+ homepage: http://rubygems.org/gems/convertify
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Currency Conversion
44
+ test_files: []