simple_forex 0.1.3 → 0.1.4

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -27
  3. data/lib/doc/CreateCurrencies.html +137 -0
  4. data/lib/doc/Object.html +114 -0
  5. data/lib/doc/SimpleForex/Currency.html +99 -0
  6. data/lib/doc/SimpleForex/Error.html +97 -0
  7. data/lib/doc/SimpleForex/Railtie.html +97 -0
  8. data/lib/doc/SimpleForex.html +254 -0
  9. data/lib/doc/SimpleForexGenerator.html +137 -0
  10. data/lib/doc/created.rid +8 -0
  11. data/lib/doc/css/fonts.css +167 -0
  12. data/lib/doc/css/rdoc.css +639 -0
  13. data/lib/doc/fonts/Lato-Light.ttf +0 -0
  14. data/lib/doc/fonts/Lato-LightItalic.ttf +0 -0
  15. data/lib/doc/fonts/Lato-Regular.ttf +0 -0
  16. data/lib/doc/fonts/Lato-RegularItalic.ttf +0 -0
  17. data/lib/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  18. data/lib/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  19. data/lib/doc/images/add.png +0 -0
  20. data/lib/doc/images/arrow_up.png +0 -0
  21. data/lib/doc/images/brick.png +0 -0
  22. data/lib/doc/images/brick_link.png +0 -0
  23. data/lib/doc/images/bug.png +0 -0
  24. data/lib/doc/images/bullet_black.png +0 -0
  25. data/lib/doc/images/bullet_toggle_minus.png +0 -0
  26. data/lib/doc/images/bullet_toggle_plus.png +0 -0
  27. data/lib/doc/images/date.png +0 -0
  28. data/lib/doc/images/delete.png +0 -0
  29. data/lib/doc/images/find.png +0 -0
  30. data/lib/doc/images/loadingAnimation.gif +0 -0
  31. data/lib/doc/images/macFFBgHack.png +0 -0
  32. data/lib/doc/images/package.png +0 -0
  33. data/lib/doc/images/page_green.png +0 -0
  34. data/lib/doc/images/page_white_text.png +0 -0
  35. data/lib/doc/images/page_white_width.png +0 -0
  36. data/lib/doc/images/plugin.png +0 -0
  37. data/lib/doc/images/ruby.png +0 -0
  38. data/lib/doc/images/tag_blue.png +0 -0
  39. data/lib/doc/images/tag_green.png +0 -0
  40. data/lib/doc/images/transparent.png +0 -0
  41. data/lib/doc/images/wrench.png +0 -0
  42. data/lib/doc/images/wrench_orange.png +0 -0
  43. data/lib/doc/images/zoom.png +0 -0
  44. data/lib/doc/index.html +94 -0
  45. data/lib/doc/js/darkfish.js +84 -0
  46. data/lib/doc/js/navigation.js +105 -0
  47. data/lib/doc/js/navigation.js.gz +0 -0
  48. data/lib/doc/js/search.js +110 -0
  49. data/lib/doc/js/search_index.js +1 -0
  50. data/lib/doc/js/search_index.js.gz +0 -0
  51. data/lib/doc/js/searcher.js +229 -0
  52. data/lib/doc/js/searcher.js.gz +0 -0
  53. data/lib/doc/simple_forex/tasks/simple_forex_rake.html +153 -0
  54. data/lib/doc/table_of_contents.html +101 -0
  55. data/lib/simple_forex/version.rb +1 -1
  56. data/lib/simple_forex.rb +92 -2
  57. metadata +69 -5
  58. data/lib/easy_money.rb +0 -109
  59. data/lib/simple_forex/.DS_Store +0 -0
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class SimpleForex::Railtie - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ var index_rel_prefix = "../";
12
+ </script>
13
+
14
+ <script src="../js/navigation.js" defer></script>
15
+ <script src="../js/search.js" defer></script>
16
+ <script src="../js/search_index.js" defer></script>
17
+ <script src="../js/searcher.js" defer></script>
18
+ <script src="../js/darkfish.js" defer></script>
19
+
20
+ <link href="../css/fonts.css" rel="stylesheet">
21
+ <link href="../css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../table_of_contents.html#pages">Pages</a>
34
+ <a href="../table_of_contents.html#classes">Classes</a>
35
+ <a href="../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+
61
+ <div id="parent-class-section" class="nav-section">
62
+ <h3>Parent</h3>
63
+
64
+ <p class="link">Rails::Railtie
65
+ </div>
66
+
67
+
68
+
69
+
70
+ </div>
71
+ </nav>
72
+
73
+ <main role="main" aria-labelledby="class-SimpleForex::Railtie">
74
+ <h1 id="class-SimpleForex::Railtie" class="class">
75
+ class SimpleForex::Railtie
76
+ </h1>
77
+
78
+ <section class="description">
79
+
80
+ </section>
81
+
82
+ <section id="5Buntitled-5D" class="documentation-section">
83
+
84
+
85
+
86
+
87
+
88
+ </section>
89
+ </main>
90
+
91
+
92
+ <footer id="validator-badges" role="contentinfo">
93
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
94
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.3.
95
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
96
+ </footer>
97
+
@@ -0,0 +1,254 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>module SimpleForex - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" role="document" class="module">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+
61
+
62
+
63
+
64
+ <!-- Method Quickref -->
65
+ <div id="method-list-section" class="nav-section">
66
+ <h3>Methods</h3>
67
+
68
+ <ul class="link-list" role="directory">
69
+ <li ><a href="#method-i-all_currencies">#all_currencies</a>
70
+ <li ><a href="#method-i-convert">#convert</a>
71
+ <li ><a href="#method-i-currency_exchange_rate">#currency_exchange_rate</a>
72
+ <li ><a href="#method-i-some_currencies">#some_currencies</a>
73
+ </ul>
74
+ </div>
75
+
76
+ </div>
77
+ </nav>
78
+
79
+ <main role="main" aria-labelledby="module-SimpleForex">
80
+ <h1 id="module-SimpleForex" class="module">
81
+ module SimpleForex
82
+ </h1>
83
+
84
+ <section class="description">
85
+
86
+ <p>Tip: open exchange rates&#39;s free API gives 1000 calls monthly, and there are ~700 hours in month, so you safely run it hourly while staying within the free limit.</p>
87
+
88
+ </section>
89
+
90
+ <section id="5Buntitled-5D" class="documentation-section">
91
+
92
+
93
+ <section class="constants-list">
94
+ <header>
95
+ <h3>Constants</h3>
96
+ </header>
97
+ <dl>
98
+ <dt id="VERSION">VERSION
99
+ <dd>
100
+ </dl>
101
+ </section>
102
+
103
+
104
+
105
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
106
+ <header>
107
+ <h3>Public Instance Methods</h3>
108
+ </header>
109
+
110
+ <div id="method-i-all_currencies" class="method-detail ">
111
+ <div class="method-heading">
112
+ <span class="method-name">all_currencies</span><span
113
+ class="method-args">()</span>
114
+ <span class="method-click-advice">click to toggle source</span>
115
+ </div>
116
+
117
+ <div class="method-description">
118
+
119
+
120
+ <div class="method-source-code" id="all_currencies-source">
121
+ <pre><span class="ruby-comment"># File simple_forex.rb, line 165</span>
122
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">all_currencies</span>
123
+ <span class="ruby-comment"># Acquired via Currency.last.blob[&#39;rates&#39;].keys</span>
124
+ [<span class="ruby-string">&quot;AED&quot;</span>, <span class="ruby-string">&quot;AFN&quot;</span>, <span class="ruby-string">&quot;ALL&quot;</span>, <span class="ruby-string">&quot;AMD&quot;</span>, <span class="ruby-string">&quot;ANG&quot;</span>, <span class="ruby-string">&quot;AOA&quot;</span>, <span class="ruby-string">&quot;ARS&quot;</span>, <span class="ruby-string">&quot;AUD&quot;</span>, <span class="ruby-string">&quot;AWG&quot;</span>, <span class="ruby-string">&quot;AZN&quot;</span>, <span class="ruby-string">&quot;BAM&quot;</span>, <span class="ruby-string">&quot;BBD&quot;</span>, <span class="ruby-string">&quot;BDT&quot;</span>, <span class="ruby-string">&quot;BGN&quot;</span>, <span class="ruby-string">&quot;BHD&quot;</span>, <span class="ruby-string">&quot;BIF&quot;</span>, <span class="ruby-string">&quot;BMD&quot;</span>, <span class="ruby-string">&quot;BND&quot;</span>, <span class="ruby-string">&quot;BOB&quot;</span>, <span class="ruby-string">&quot;BRL&quot;</span>, <span class="ruby-string">&quot;BSD&quot;</span>, <span class="ruby-string">&quot;BTC&quot;</span>, <span class="ruby-string">&quot;BTN&quot;</span>, <span class="ruby-string">&quot;BWP&quot;</span>, <span class="ruby-string">&quot;BYN&quot;</span>, <span class="ruby-string">&quot;BZD&quot;</span>, <span class="ruby-string">&quot;CAD&quot;</span>, <span class="ruby-string">&quot;CDF&quot;</span>, <span class="ruby-string">&quot;CHF&quot;</span>, <span class="ruby-string">&quot;CLF&quot;</span>, <span class="ruby-string">&quot;CLP&quot;</span>, <span class="ruby-string">&quot;CNH&quot;</span>, <span class="ruby-string">&quot;CNY&quot;</span>, <span class="ruby-string">&quot;COP&quot;</span>, <span class="ruby-string">&quot;CRC&quot;</span>, <span class="ruby-string">&quot;CUC&quot;</span>, <span class="ruby-string">&quot;CUP&quot;</span>, <span class="ruby-string">&quot;CVE&quot;</span>, <span class="ruby-string">&quot;CZK&quot;</span>, <span class="ruby-string">&quot;DJF&quot;</span>, <span class="ruby-string">&quot;DKK&quot;</span>, <span class="ruby-string">&quot;DOP&quot;</span>, <span class="ruby-string">&quot;DZD&quot;</span>, <span class="ruby-string">&quot;EGP&quot;</span>, <span class="ruby-string">&quot;ERN&quot;</span>, <span class="ruby-string">&quot;ETB&quot;</span>, <span class="ruby-string">&quot;EUR&quot;</span>, <span class="ruby-string">&quot;FJD&quot;</span>, <span class="ruby-string">&quot;FKP&quot;</span>, <span class="ruby-string">&quot;GBP&quot;</span>, <span class="ruby-string">&quot;GEL&quot;</span>, <span class="ruby-string">&quot;GGP&quot;</span>, <span class="ruby-string">&quot;GHS&quot;</span>, <span class="ruby-string">&quot;GIP&quot;</span>, <span class="ruby-string">&quot;GMD&quot;</span>, <span class="ruby-string">&quot;GNF&quot;</span>, <span class="ruby-string">&quot;GTQ&quot;</span>, <span class="ruby-string">&quot;GYD&quot;</span>, <span class="ruby-string">&quot;HKD&quot;</span>, <span class="ruby-string">&quot;HNL&quot;</span>, <span class="ruby-string">&quot;HRK&quot;</span>, <span class="ruby-string">&quot;HTG&quot;</span>, <span class="ruby-string">&quot;HUF&quot;</span>, <span class="ruby-string">&quot;IDR&quot;</span>, <span class="ruby-string">&quot;ILS&quot;</span>, <span class="ruby-string">&quot;IMP&quot;</span>, <span class="ruby-string">&quot;INR&quot;</span>, <span class="ruby-string">&quot;IQD&quot;</span>, <span class="ruby-string">&quot;IRR&quot;</span>, <span class="ruby-string">&quot;ISK&quot;</span>, <span class="ruby-string">&quot;JEP&quot;</span>, <span class="ruby-string">&quot;JMD&quot;</span>, <span class="ruby-string">&quot;JOD&quot;</span>, <span class="ruby-string">&quot;JPY&quot;</span>, <span class="ruby-string">&quot;KES&quot;</span>, <span class="ruby-string">&quot;KGS&quot;</span>, <span class="ruby-string">&quot;KHR&quot;</span>, <span class="ruby-string">&quot;KMF&quot;</span>, <span class="ruby-string">&quot;KPW&quot;</span>, <span class="ruby-string">&quot;KRW&quot;</span>, <span class="ruby-string">&quot;KWD&quot;</span>, <span class="ruby-string">&quot;KYD&quot;</span>, <span class="ruby-string">&quot;KZT&quot;</span>, <span class="ruby-string">&quot;LAK&quot;</span>, <span class="ruby-string">&quot;LBP&quot;</span>, <span class="ruby-string">&quot;LKR&quot;</span>, <span class="ruby-string">&quot;LRD&quot;</span>, <span class="ruby-string">&quot;LSL&quot;</span>, <span class="ruby-string">&quot;LYD&quot;</span>, <span class="ruby-string">&quot;MAD&quot;</span>, <span class="ruby-string">&quot;MDL&quot;</span>, <span class="ruby-string">&quot;MGA&quot;</span>, <span class="ruby-string">&quot;MKD&quot;</span>, <span class="ruby-string">&quot;MMK&quot;</span>, <span class="ruby-string">&quot;MNT&quot;</span>, <span class="ruby-string">&quot;MOP&quot;</span>, <span class="ruby-string">&quot;MRU&quot;</span>, <span class="ruby-string">&quot;MUR&quot;</span>, <span class="ruby-string">&quot;MVR&quot;</span>, <span class="ruby-string">&quot;MWK&quot;</span>, <span class="ruby-string">&quot;MXN&quot;</span>, <span class="ruby-string">&quot;MYR&quot;</span>, <span class="ruby-string">&quot;MZN&quot;</span>, <span class="ruby-string">&quot;NAD&quot;</span>, <span class="ruby-string">&quot;NGN&quot;</span>, <span class="ruby-string">&quot;NIO&quot;</span>, <span class="ruby-string">&quot;NOK&quot;</span>, <span class="ruby-string">&quot;NPR&quot;</span>, <span class="ruby-string">&quot;NZD&quot;</span>, <span class="ruby-string">&quot;OMR&quot;</span>, <span class="ruby-string">&quot;PAB&quot;</span>, <span class="ruby-string">&quot;PEN&quot;</span>, <span class="ruby-string">&quot;PGK&quot;</span>, <span class="ruby-string">&quot;PHP&quot;</span>, <span class="ruby-string">&quot;PKR&quot;</span>, <span class="ruby-string">&quot;PLN&quot;</span>, <span class="ruby-string">&quot;PYG&quot;</span>, <span class="ruby-string">&quot;QAR&quot;</span>, <span class="ruby-string">&quot;RON&quot;</span>, <span class="ruby-string">&quot;RSD&quot;</span>, <span class="ruby-string">&quot;RUB&quot;</span>, <span class="ruby-string">&quot;RWF&quot;</span>, <span class="ruby-string">&quot;SAR&quot;</span>, <span class="ruby-string">&quot;SBD&quot;</span>, <span class="ruby-string">&quot;SCR&quot;</span>, <span class="ruby-string">&quot;SDG&quot;</span>, <span class="ruby-string">&quot;SEK&quot;</span>, <span class="ruby-string">&quot;SGD&quot;</span>, <span class="ruby-string">&quot;SHP&quot;</span>, <span class="ruby-string">&quot;SLL&quot;</span>, <span class="ruby-string">&quot;SOS&quot;</span>, <span class="ruby-string">&quot;SRD&quot;</span>, <span class="ruby-string">&quot;SSP&quot;</span>, <span class="ruby-string">&quot;STD&quot;</span>, <span class="ruby-string">&quot;STN&quot;</span>, <span class="ruby-string">&quot;SVC&quot;</span>, <span class="ruby-string">&quot;SYP&quot;</span>, <span class="ruby-string">&quot;SZL&quot;</span>, <span class="ruby-string">&quot;THB&quot;</span>, <span class="ruby-string">&quot;TJS&quot;</span>, <span class="ruby-string">&quot;TMT&quot;</span>, <span class="ruby-string">&quot;TND&quot;</span>, <span class="ruby-string">&quot;TOP&quot;</span>, <span class="ruby-string">&quot;TRY&quot;</span>, <span class="ruby-string">&quot;TTD&quot;</span>, <span class="ruby-string">&quot;TWD&quot;</span>, <span class="ruby-string">&quot;TZS&quot;</span>, <span class="ruby-string">&quot;UAH&quot;</span>, <span class="ruby-string">&quot;UGX&quot;</span>, <span class="ruby-string">&quot;USD&quot;</span>, <span class="ruby-string">&quot;UYU&quot;</span>, <span class="ruby-string">&quot;UZS&quot;</span>, <span class="ruby-string">&quot;VES&quot;</span>, <span class="ruby-string">&quot;VND&quot;</span>, <span class="ruby-string">&quot;VUV&quot;</span>, <span class="ruby-string">&quot;WST&quot;</span>, <span class="ruby-string">&quot;XAF&quot;</span>, <span class="ruby-string">&quot;XAG&quot;</span>, <span class="ruby-string">&quot;XAU&quot;</span>, <span class="ruby-string">&quot;XCD&quot;</span>, <span class="ruby-string">&quot;XDR&quot;</span>, <span class="ruby-string">&quot;XOF&quot;</span>, <span class="ruby-string">&quot;XPD&quot;</span>, <span class="ruby-string">&quot;XPF&quot;</span>, <span class="ruby-string">&quot;XPT&quot;</span>, <span class="ruby-string">&quot;YER&quot;</span>, <span class="ruby-string">&quot;ZAR&quot;</span>, <span class="ruby-string">&quot;ZMW&quot;</span>, <span class="ruby-string">&quot;ZWL&quot;</span>]
125
+ <span class="ruby-keyword">end</span></pre>
126
+ </div>
127
+ </div>
128
+
129
+
130
+ </div>
131
+
132
+ <div id="method-i-convert" class="method-detail ">
133
+ <div class="method-heading">
134
+ <span class="method-name">convert</span><span
135
+ class="method-args">(amount, from_currency, to_currency)</span>
136
+ <span class="method-click-advice">click to toggle source</span>
137
+ </div>
138
+
139
+ <div class="method-description">
140
+
141
+
142
+ <div class="method-source-code" id="convert-source">
143
+ <pre><span class="ruby-comment"># File simple_forex.rb, line 145</span>
144
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">convert</span>(<span class="ruby-identifier">amount</span>, <span class="ruby-identifier">from_currency</span>, <span class="ruby-identifier">to_currency</span>)
145
+ <span class="ruby-comment"># Examples:</span>
146
+ <span class="ruby-comment"># convert(100, &quot;aud&quot;, &quot;gbp&quot;) # 54.585</span>
147
+ <span class="ruby-comment"># convert(100, &quot;gbp&quot;, &quot;aud&quot;) # 183.2</span>
148
+ <span class="ruby-comment"># convert(100, &quot;usd&quot;, &quot;aud&quot;) # 129.0</span>
149
+ <span class="ruby-comment"># convert(100, &quot;aud&quot;, &quot;usd&quot;) # 77.0</span>
150
+ <span class="ruby-keyword">begin</span>
151
+ <span class="ruby-identifier">rate</span> = <span class="ruby-identifier">currency_exchange_rate</span>(<span class="ruby-identifier">from_currency</span>, <span class="ruby-identifier">to_currency</span>)
152
+ <span class="ruby-keyword">rescue</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">exception</span>
153
+ <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Error: #{exception} - \n\nYou could be seeing this error if you forgot to setup the database and fetch currency data.
154
+ \nDid you forget to run `rails g simple_forex:install`, `rake db:migrate` or `rake simple_forex:fetch_rates`?
155
+ \nSee documentation for more information: https://github.com/stevecondylios/SimpleForex\n\n&quot;</span>
156
+ <span class="ruby-keyword">end</span>
157
+
158
+ <span class="ruby-identifier">converted_amount</span> = <span class="ruby-identifier">amount</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">rate</span>
159
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">converted_amount</span>
160
+ <span class="ruby-keyword">end</span></pre>
161
+ </div>
162
+ </div>
163
+
164
+
165
+ </div>
166
+
167
+ <div id="method-i-currency_exchange_rate" class="method-detail ">
168
+ <div class="method-heading">
169
+ <span class="method-name">currency_exchange_rate</span><span
170
+ class="method-args">(from, to)</span>
171
+ <span class="method-click-advice">click to toggle source</span>
172
+ </div>
173
+
174
+ <div class="method-description">
175
+
176
+
177
+ <div class="method-source-code" id="currency_exchange_rate-source">
178
+ <pre><span class="ruby-comment"># File simple_forex.rb, line 105</span>
179
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">currency_exchange_rate</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
180
+
181
+ <span class="ruby-identifier">currencies</span> = <span class="ruby-constant">Currency</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">blob</span>
182
+
183
+ <span class="ruby-comment"># Tests:</span>
184
+ <span class="ruby-comment"># currency_exchange_rate(&quot;aud&quot;, &quot;gbp&quot;) # 0.54</span>
185
+ <span class="ruby-comment"># currency_exchange_rate(&quot;GBP&quot;, &quot;AUD&quot;) # 1.832</span>
186
+ <span class="ruby-comment"># currency_exchange_rate(&quot;USD&quot;, &quot;AUD&quot;) # 1.29</span>
187
+ <span class="ruby-comment"># currency_exchange_rate(&quot;AUD&quot;, &quot;usd&quot;) # 0.77</span>
188
+
189
+ <span class="ruby-comment"># The open exchange rate API uses UPPER case (unlike stripe and some other platforms)</span>
190
+ <span class="ruby-identifier">from</span> = <span class="ruby-identifier">from</span>.<span class="ruby-identifier">upcase</span>
191
+ <span class="ruby-identifier">to</span> = <span class="ruby-identifier">to</span>.<span class="ruby-identifier">upcase</span>
192
+
193
+ <span class="ruby-identifier">error_message</span> = <span class="ruby-string">&quot;&quot;</span><span class="ruby-string">&quot;
194
+ The currency %{currency_code} is not a valid currency code.
195
+ Run `Currency.last.blob[\&quot;rates\&quot;].keys` to view
196
+ available currencies.
197
+ &quot;</span><span class="ruby-string">&quot;&quot;</span>
198
+ <span class="ruby-comment"># from = &quot;AUDz&quot;</span>
199
+ <span class="ruby-comment"># error_message % {currency_code: from}</span>
200
+
201
+ <span class="ruby-identifier">raise</span> <span class="ruby-identifier">error_message</span> <span class="ruby-operator">%</span> {<span class="ruby-value">currency_code:</span> <span class="ruby-identifier">from</span>} <span class="ruby-keyword">unless</span> <span class="ruby-identifier">currencies</span>[<span class="ruby-string">&quot;rates&quot;</span>].<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">from</span>
202
+ <span class="ruby-identifier">raise</span> <span class="ruby-identifier">error_message</span> <span class="ruby-operator">%</span> {<span class="ruby-value">currency_code:</span> <span class="ruby-identifier">to</span>} <span class="ruby-keyword">unless</span> <span class="ruby-identifier">currencies</span>[<span class="ruby-string">&quot;rates&quot;</span>].<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">to</span>
203
+
204
+
205
+ <span class="ruby-identifier">usd_to_from</span> = <span class="ruby-identifier">currencies</span>[<span class="ruby-string">&#39;rates&#39;</span>][<span class="ruby-identifier">from</span>].<span class="ruby-identifier">to_d</span>
206
+ <span class="ruby-identifier">usd_to_to</span> = <span class="ruby-identifier">currencies</span>[<span class="ruby-string">&#39;rates&#39;</span>][<span class="ruby-identifier">to</span>].<span class="ruby-identifier">to_d</span>
207
+ <span class="ruby-identifier">rate</span> = <span class="ruby-identifier">usd_to_to</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">usd_to_from</span>
208
+ <span class="ruby-comment"># This converts 1 AUD to GPD (gives 0.54585)</span>
209
+ <span class="ruby-comment"># R example: rates$rates$GBP / rates$rates$AUD</span>
210
+ <span class="ruby-comment"># Ruby: currency[&#39;rates&#39;][&#39;GBP&#39;].to_d / currency[&#39;rates&#39;][&#39;AUD&#39;].to_d</span>
211
+
212
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">rate</span>
213
+
214
+
215
+ <span class="ruby-keyword">end</span></pre>
216
+ </div>
217
+ </div>
218
+
219
+
220
+ </div>
221
+
222
+ <div id="method-i-some_currencies" class="method-detail ">
223
+ <div class="method-heading">
224
+ <span class="method-name">some_currencies</span><span
225
+ class="method-args">()</span>
226
+ <span class="method-click-advice">click to toggle source</span>
227
+ </div>
228
+
229
+ <div class="method-description">
230
+
231
+
232
+ <div class="method-source-code" id="some_currencies-source">
233
+ <pre><span class="ruby-comment"># File simple_forex.rb, line 173</span>
234
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">some_currencies</span>
235
+ [<span class="ruby-string">&quot;AUD&quot;</span>, <span class="ruby-string">&quot;CAD&quot;</span>, <span class="ruby-string">&quot;EUR&quot;</span>, <span class="ruby-string">&quot;GBP&quot;</span>, <span class="ruby-string">&quot;HKD&quot;</span>, <span class="ruby-string">&quot;NZD&quot;</span>, <span class="ruby-string">&quot;SGD&quot;</span>, <span class="ruby-string">&quot;USD&quot;</span>]
236
+ <span class="ruby-keyword">end</span></pre>
237
+ </div>
238
+ </div>
239
+
240
+
241
+ </div>
242
+
243
+ </section>
244
+
245
+ </section>
246
+ </main>
247
+
248
+
249
+ <footer id="validator-badges" role="contentinfo">
250
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
251
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.3.
252
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
253
+ </footer>
254
+
@@ -0,0 +1,137 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class SimpleForexGenerator - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+
61
+ <div id="parent-class-section" class="nav-section">
62
+ <h3>Parent</h3>
63
+
64
+ <p class="link">ActiveRecord::Generators::Base
65
+ </div>
66
+
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+ <li ><a href="#method-i-copy_files">#copy_files</a>
76
+ </ul>
77
+ </div>
78
+
79
+ </div>
80
+ </nav>
81
+
82
+ <main role="main" aria-labelledby="class-SimpleForexGenerator">
83
+ <h1 id="class-SimpleForexGenerator" class="class">
84
+ class SimpleForexGenerator
85
+ </h1>
86
+
87
+ <section class="description">
88
+
89
+ <p>This generator adds a migration for the {FriendlyId::History FriendlyId::History} addon.</p>
90
+
91
+ </section>
92
+
93
+ <section id="5Buntitled-5D" class="documentation-section">
94
+
95
+
96
+
97
+
98
+
99
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
100
+ <header>
101
+ <h3>Public Instance Methods</h3>
102
+ </header>
103
+
104
+ <div id="method-i-copy_files" class="method-detail ">
105
+ <div class="method-heading">
106
+ <span class="method-name">copy_files</span><span
107
+ class="method-args">()</span>
108
+ <span class="method-click-advice">click to toggle source</span>
109
+ </div>
110
+
111
+ <div class="method-description">
112
+ <p>Copies the migration template to db/migrate.</p>
113
+
114
+ <div class="method-source-code" id="copy_files-source">
115
+ <pre><span class="ruby-comment"># File generators/simple_forex/simple_forex_generator.rb, line 17</span>
116
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_files</span>
117
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-string">&quot;skip-migration&quot;</span>]
118
+ <span class="ruby-identifier">migration_template</span> <span class="ruby-string">&quot;migration.rb&quot;</span>, <span class="ruby-string">&quot;db/migrate/create_currencies.rb&quot;</span>
119
+ <span class="ruby-keyword">end</span></pre>
120
+ </div>
121
+ </div>
122
+
123
+
124
+ </div>
125
+
126
+ </section>
127
+
128
+ </section>
129
+ </main>
130
+
131
+
132
+ <footer id="validator-badges" role="contentinfo">
133
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
134
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.3.
135
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
136
+ </footer>
137
+
@@ -0,0 +1,8 @@
1
+ Wed, 08 Mar 2023 02:32:29 +1100
2
+ generators/simple_forex/simple_forex_generator.rb Sun, 05 Mar 2023 15:40:13 +1100
3
+ simple_forex/initializer.rb Sun, 05 Mar 2023 05:24:40 +1100
4
+ simple_forex/migration.rb Sun, 05 Mar 2023 04:40:55 +1100
5
+ simple_forex/railtie.rb Tue, 07 Mar 2023 20:44:05 +1100
6
+ simple_forex/tasks/simple_forex.rake Mon, 06 Mar 2023 04:35:56 +1100
7
+ simple_forex/version.rb Wed, 08 Mar 2023 02:31:10 +1100
8
+ simple_forex.rb Wed, 08 Mar 2023 02:24:07 +1100