currency_spy 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +8 -1
- data/README.rdoc +8 -0
- data/currency_spy.gemspec +1 -0
- data/doc/CurrencySpy.html +277 -0
- data/doc/CurrencySpy/DnbNord.html +454 -0
- data/doc/CurrencySpy/Nbp.html +377 -0
- data/doc/CurrencySpy/Scraper.html +461 -0
- data/doc/CurrencySpy/Walutomat.html +331 -0
- data/doc/Gemfile.html +106 -0
- data/doc/LICENSE.html +125 -0
- data/doc/README_rdoc.html +149 -0
- data/doc/Rakefile.html +103 -0
- data/doc/created.rid +17 -0
- data/doc/index.html +106 -0
- data/doc/lib/currency_spy/dnb_nord_rb.html +52 -0
- data/doc/lib/currency_spy/nbp_rb.html +52 -0
- data/doc/lib/currency_spy/scraper_rb.html +52 -0
- data/doc/lib/currency_spy/version_rb.html +52 -0
- data/doc/lib/currency_spy/walutomat_rb.html +52 -0
- data/doc/lib/currency_spy_rb.html +56 -0
- data/doc/rdoc.css +706 -0
- data/doc/spec/dnb_nord_spec_rb.html +54 -0
- data/doc/spec/nbp_spec_rb.html +54 -0
- data/doc/spec/scraper_spec_rb.html +54 -0
- data/doc/spec/spec_helper_rb.html +56 -0
- data/doc/spec/walutomat_spec_rb.html +54 -0
- data/lib/currency_spy.rb +17 -1
- data/lib/currency_spy/dnb_nord.rb +57 -0
- data/lib/currency_spy/nbp.rb +17 -9
- data/lib/currency_spy/scraper.rb +52 -23
- data/lib/currency_spy/version.rb +2 -1
- data/lib/currency_spy/walutomat.rb +43 -0
- data/spec/dnb_nord_spec.rb +47 -0
- data/spec/nbp_spec.rb +8 -0
- data/spec/scraper_spec.rb +26 -16
- data/spec/walutomat_spec.rb +33 -0
- metadata +45 -3
data/Gemfile.lock
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
currency_spy (0.0.
|
4
|
+
currency_spy (0.0.2)
|
5
|
+
bundler
|
6
|
+
mechanize
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: http://rubygems.org/
|
8
10
|
specs:
|
9
11
|
diff-lcs (1.1.2)
|
12
|
+
mechanize (1.0.0)
|
13
|
+
nokogiri (>= 1.2.1)
|
14
|
+
nokogiri (1.4.4)
|
10
15
|
rspec (2.4.0)
|
11
16
|
rspec-core (~> 2.4.0)
|
12
17
|
rspec-expectations (~> 2.4.0)
|
@@ -20,5 +25,7 @@ PLATFORMS
|
|
20
25
|
ruby
|
21
26
|
|
22
27
|
DEPENDENCIES
|
28
|
+
bundler
|
23
29
|
currency_spy!
|
30
|
+
mechanize
|
24
31
|
rspec
|
data/README.rdoc
CHANGED
@@ -25,6 +25,14 @@ You can also clone my GitHub repository
|
|
25
25
|
(git://github.com/lbadura/currency_spy.git) and build the gem yourself and / or
|
26
26
|
hack on it.
|
27
27
|
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
The usage is really simple. To fetch rates from given source just instantiate
|
31
|
+
a class which represents that source and call fetch_rates on it:
|
32
|
+
nbp = CurrencySpy::Nbp.new
|
33
|
+
rates = nbp.fetch_rates
|
34
|
+
=> {:buy_rate=>3.8482, :sell_rate=>3.926, :rate_time=>#<DateTime:2011-01-07T00:00:00+00:00 (4911137/2,0/1,2299161)>}
|
35
|
+
|
28
36
|
== Credits
|
29
37
|
|
30
38
|
Feel free to contact me at lukasz@niebo.net.
|
data/currency_spy.gemspec
CHANGED
@@ -0,0 +1,277 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: CurrencySpy</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="module">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="./lib/currency_spy_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/currency_spy.rb">lib/currency_spy.rb</a></li>
|
43
|
+
|
44
|
+
<li><a href="./lib/currency_spy/version_rb.html?TB_iframe=true&height=550&width=785"
|
45
|
+
class="thickbox" title="lib/currency_spy/version.rb">lib/currency_spy/version.rb</a></li>
|
46
|
+
|
47
|
+
<li><a href="./lib/currency_spy/nbp_rb.html?TB_iframe=true&height=550&width=785"
|
48
|
+
class="thickbox" title="lib/currency_spy/nbp.rb">lib/currency_spy/nbp.rb</a></li>
|
49
|
+
|
50
|
+
<li><a href="./lib/currency_spy/dnb_nord_rb.html?TB_iframe=true&height=550&width=785"
|
51
|
+
class="thickbox" title="lib/currency_spy/dnb_nord.rb">lib/currency_spy/dnb_nord.rb</a></li>
|
52
|
+
|
53
|
+
<li><a href="./lib/currency_spy/scraper_rb.html?TB_iframe=true&height=550&width=785"
|
54
|
+
class="thickbox" title="lib/currency_spy/scraper.rb">lib/currency_spy/scraper.rb</a></li>
|
55
|
+
|
56
|
+
<li><a href="./lib/currency_spy/walutomat_rb.html?TB_iframe=true&height=550&width=785"
|
57
|
+
class="thickbox" title="lib/currency_spy/walutomat.rb">lib/currency_spy/walutomat.rb</a></li>
|
58
|
+
|
59
|
+
</ul>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div id="class-metadata">
|
67
|
+
|
68
|
+
<!-- Parent Class -->
|
69
|
+
|
70
|
+
|
71
|
+
<!-- Namespace Contents -->
|
72
|
+
|
73
|
+
<div id="namespace-list-section" class="section">
|
74
|
+
<h3 class="section-header">Namespace</h3>
|
75
|
+
<ul class="link-list">
|
76
|
+
|
77
|
+
<li><span class="type">CLASS</span> <a href="CurrencySpy/DnbNord.html">CurrencySpy::DnbNord</a></li>
|
78
|
+
|
79
|
+
<li><span class="type">CLASS</span> <a href="CurrencySpy/Nbp.html">CurrencySpy::Nbp</a></li>
|
80
|
+
|
81
|
+
<li><span class="type">CLASS</span> <a href="CurrencySpy/Scraper.html">CurrencySpy::Scraper</a></li>
|
82
|
+
|
83
|
+
<li><span class="type">CLASS</span> <a href="CurrencySpy/Walutomat.html">CurrencySpy::Walutomat</a></li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
<!-- Method Quickref -->
|
90
|
+
|
91
|
+
<div id="method-list-section" class="section">
|
92
|
+
<h3 class="section-header">Methods</h3>
|
93
|
+
<ul class="link-list">
|
94
|
+
|
95
|
+
<li><a href="#method-c-datestr">::datestr</a></li>
|
96
|
+
|
97
|
+
</ul>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
<!-- Included Modules -->
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<div id="project-metadata">
|
106
|
+
|
107
|
+
|
108
|
+
<div id="fileindex-section" class="section project-section">
|
109
|
+
<h3 class="section-header">Files</h3>
|
110
|
+
<ul>
|
111
|
+
|
112
|
+
<li class="file"><a href="./Gemfile.html">Gemfile</a></li>
|
113
|
+
|
114
|
+
<li class="file"><a href="./LICENSE.html">LICENSE</a></li>
|
115
|
+
|
116
|
+
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
117
|
+
|
118
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
|
119
|
+
|
120
|
+
<li class="file"><a href="./nbproject/private/rake-d_txt.html">rake-d.txt</a></li>
|
121
|
+
|
122
|
+
</ul>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
|
126
|
+
<div id="classindex-section" class="section project-section">
|
127
|
+
<h3 class="section-header">Class Index
|
128
|
+
<span class="search-toggle"><img src="./images/find.png"
|
129
|
+
height="16" width="16" alt="[+]"
|
130
|
+
title="show/hide quicksearch" /></span></h3>
|
131
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
132
|
+
<fieldset>
|
133
|
+
<legend>Quicksearch</legend>
|
134
|
+
<input type="text" name="quicksearch" value=""
|
135
|
+
class="quicksearch-field" />
|
136
|
+
</fieldset>
|
137
|
+
</form>
|
138
|
+
|
139
|
+
<ul class="link-list">
|
140
|
+
|
141
|
+
<li><a href="./CurrencySpy.html">CurrencySpy</a></li>
|
142
|
+
|
143
|
+
<li><a href="./CurrencySpy/DnbNord.html">CurrencySpy::DnbNord</a></li>
|
144
|
+
|
145
|
+
<li><a href="./CurrencySpy/Nbp.html">CurrencySpy::Nbp</a></li>
|
146
|
+
|
147
|
+
<li><a href="./CurrencySpy/Scraper.html">CurrencySpy::Scraper</a></li>
|
148
|
+
|
149
|
+
<li><a href="./CurrencySpy/Walutomat.html">CurrencySpy::Walutomat</a></li>
|
150
|
+
|
151
|
+
</ul>
|
152
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
153
|
+
</div>
|
154
|
+
|
155
|
+
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
|
159
|
+
<div id="documentation">
|
160
|
+
<h1 class="module">CurrencySpy</h1>
|
161
|
+
|
162
|
+
<div id="description">
|
163
|
+
<p>
|
164
|
+
This gem is a set of scrapers to fetch currencies from various
|
165
|
+
institutions’ websites. It’s primary use is to monitor the
|
166
|
+
changes of currency rates across different institutions to calculate
|
167
|
+
spreads (difference between the buying rate and the selling rate. It
|
168
|
+
fetches the rates in PLN (Polish Zloty) however if there’s a demand I
|
169
|
+
could extend the gem to be more flexible.
|
170
|
+
</p>
|
171
|
+
<table>
|
172
|
+
<tr><td valign="top">Author</td><td><p>
|
173
|
+
Łukasz Badura (<a href="mailto:lukasz@niebo.net">lukasz@niebo.net</a>)
|
174
|
+
</p>
|
175
|
+
</td></tr>
|
176
|
+
<tr><td valign="top">Copyright</td><td><p>
|
177
|
+
Copyright © 2011 Łukasz Badura
|
178
|
+
</p>
|
179
|
+
</td></tr>
|
180
|
+
<tr><td valign="top">License</td><td><p>
|
181
|
+
MIT license.
|
182
|
+
</p>
|
183
|
+
</td></tr>
|
184
|
+
</table>
|
185
|
+
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<!-- Constants -->
|
189
|
+
|
190
|
+
<div id="constants-list" class="section">
|
191
|
+
<h3 class="section-header">Constants</h3>
|
192
|
+
<dl>
|
193
|
+
|
194
|
+
<dt><a name="DATE_FORMAT">DATE_FORMAT</a></dt>
|
195
|
+
|
196
|
+
<dd class="description"><p>
|
197
|
+
Default date format used for date presentation across the code
|
198
|
+
</p></dd>
|
199
|
+
|
200
|
+
|
201
|
+
<dt><a name="VERSION">VERSION</a></dt>
|
202
|
+
|
203
|
+
<dd class="description"><p>
|
204
|
+
Stores the version of the currency_spy gem
|
205
|
+
</p></dd>
|
206
|
+
|
207
|
+
|
208
|
+
</dl>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
|
212
|
+
<!-- Attributes -->
|
213
|
+
|
214
|
+
|
215
|
+
<!-- Methods -->
|
216
|
+
|
217
|
+
<div id="public-class-method-details" class="method-section section">
|
218
|
+
<h3 class="section-header">Public Class Methods</h3>
|
219
|
+
|
220
|
+
|
221
|
+
<div id="datestr-method" class="method-detail ">
|
222
|
+
<a name="method-c-datestr"></a>
|
223
|
+
|
224
|
+
<div class="method-heading">
|
225
|
+
|
226
|
+
<span class="method-name">datestr</span><span
|
227
|
+
class="method-args">(date)</span>
|
228
|
+
<span class="method-click-advice">click to toggle source</span>
|
229
|
+
|
230
|
+
</div>
|
231
|
+
|
232
|
+
<div class="method-description">
|
233
|
+
|
234
|
+
<p>
|
235
|
+
Returns a string representation of a given date in the default format
|
236
|
+
</p>
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
<div class="method-source-code"
|
241
|
+
id="datestr-source">
|
242
|
+
<pre>
|
243
|
+
<span class="ruby-comment cmt"># File lib/currency_spy.rb, line 25</span>
|
244
|
+
25: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">datestr</span>(<span class="ruby-identifier">date</span>)
|
245
|
+
26: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-constant">CurrencySpy</span><span class="ruby-operator">::</span><span class="ruby-constant">DATE_FORMAT</span>)
|
246
|
+
27: <span class="ruby-keyword kw">end</span></pre>
|
247
|
+
</div>
|
248
|
+
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
</div>
|
255
|
+
|
256
|
+
|
257
|
+
</div>
|
258
|
+
|
259
|
+
|
260
|
+
</div>
|
261
|
+
|
262
|
+
|
263
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
264
|
+
|
265
|
+
<p>Disabled; run with --debug to generate this.</p>
|
266
|
+
|
267
|
+
</div>
|
268
|
+
|
269
|
+
<div id="validator-badges">
|
270
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
271
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
272
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
273
|
+
</div>
|
274
|
+
|
275
|
+
</body>
|
276
|
+
</html>
|
277
|
+
|
@@ -0,0 +1,454 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: CurrencySpy::DnbNord</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="../js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="../js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="class">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="../index.html">Home</a>
|
29
|
+
<a href="../index.html#classes">Classes</a>
|
30
|
+
<a href="../index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="../lib/currency_spy/dnb_nord_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/currency_spy/dnb_nord.rb">lib/currency_spy/dnb_nord.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
<div id="parent-class-section" class="section">
|
56
|
+
<h3 class="section-header">Parent</h3>
|
57
|
+
|
58
|
+
<p class="link"><a href="Scraper.html">CurrencySpy::Scraper</a></p>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Namespace Contents -->
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Method Quickref -->
|
67
|
+
|
68
|
+
<div id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
<li><a href="#method-c-new">::new</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-buy_rate">#buy_rate</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-rate_time">#rate_time</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-sell_rate">#sell_rate</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-url">#url</a></li>
|
81
|
+
|
82
|
+
</ul>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
<!-- Included Modules -->
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
<div id="project-metadata">
|
91
|
+
|
92
|
+
|
93
|
+
<div id="fileindex-section" class="section project-section">
|
94
|
+
<h3 class="section-header">Files</h3>
|
95
|
+
<ul>
|
96
|
+
|
97
|
+
<li class="file"><a href="../Gemfile.html">Gemfile</a></li>
|
98
|
+
|
99
|
+
<li class="file"><a href="../LICENSE.html">LICENSE</a></li>
|
100
|
+
|
101
|
+
<li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
|
102
|
+
|
103
|
+
<li class="file"><a href="../Rakefile.html">Rakefile</a></li>
|
104
|
+
|
105
|
+
<li class="file"><a href="../nbproject/private/rake-d_txt.html">rake-d.txt</a></li>
|
106
|
+
|
107
|
+
</ul>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
|
111
|
+
<div id="classindex-section" class="section project-section">
|
112
|
+
<h3 class="section-header">Class Index
|
113
|
+
<span class="search-toggle"><img src="../images/find.png"
|
114
|
+
height="16" width="16" alt="[+]"
|
115
|
+
title="show/hide quicksearch" /></span></h3>
|
116
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
117
|
+
<fieldset>
|
118
|
+
<legend>Quicksearch</legend>
|
119
|
+
<input type="text" name="quicksearch" value=""
|
120
|
+
class="quicksearch-field" />
|
121
|
+
</fieldset>
|
122
|
+
</form>
|
123
|
+
|
124
|
+
<ul class="link-list">
|
125
|
+
|
126
|
+
<li><a href="../CurrencySpy.html">CurrencySpy</a></li>
|
127
|
+
|
128
|
+
<li><a href="../CurrencySpy/DnbNord.html">CurrencySpy::DnbNord</a></li>
|
129
|
+
|
130
|
+
<li><a href="../CurrencySpy/Nbp.html">CurrencySpy::Nbp</a></li>
|
131
|
+
|
132
|
+
<li><a href="../CurrencySpy/Scraper.html">CurrencySpy::Scraper</a></li>
|
133
|
+
|
134
|
+
<li><a href="../CurrencySpy/Walutomat.html">CurrencySpy::Walutomat</a></li>
|
135
|
+
|
136
|
+
</ul>
|
137
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
138
|
+
</div>
|
139
|
+
|
140
|
+
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div id="documentation">
|
145
|
+
<h1 class="class">CurrencySpy::DnbNord</h1>
|
146
|
+
|
147
|
+
<div id="description">
|
148
|
+
<p>
|
149
|
+
Class designed to fetch data from DnB Nord’s website.
|
150
|
+
</p>
|
151
|
+
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<!-- Constants -->
|
155
|
+
|
156
|
+
|
157
|
+
<!-- Attributes -->
|
158
|
+
|
159
|
+
<div id="attribute-method-details" class="method-section section">
|
160
|
+
<h3 class="section-header">Attributes</h3>
|
161
|
+
|
162
|
+
|
163
|
+
<div id="session-date-attribute-method" class="method-detail">
|
164
|
+
<a name="session_date"></a>
|
165
|
+
|
166
|
+
<a name="session_date="></a>
|
167
|
+
|
168
|
+
<div class="method-heading attribute-method-heading">
|
169
|
+
<span class="method-name">session_date</span><span
|
170
|
+
class="attribute-access-type">[RW]</span>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<div class="method-description">
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
<div id="session-no-attribute-method" class="method-detail">
|
181
|
+
<a name="session_no"></a>
|
182
|
+
|
183
|
+
<a name="session_no="></a>
|
184
|
+
|
185
|
+
<div class="method-heading attribute-method-heading">
|
186
|
+
<span class="method-name">session_no</span><span
|
187
|
+
class="attribute-access-type">[RW]</span>
|
188
|
+
</div>
|
189
|
+
|
190
|
+
<div class="method-description">
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
</div>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
<!-- Methods -->
|
201
|
+
|
202
|
+
<div id="public-class-method-details" class="method-section section">
|
203
|
+
<h3 class="section-header">Public Class Methods</h3>
|
204
|
+
|
205
|
+
|
206
|
+
<div id="new-method" class="method-detail ">
|
207
|
+
<a name="method-c-new"></a>
|
208
|
+
|
209
|
+
<div class="method-heading">
|
210
|
+
|
211
|
+
<span class="method-name">new</span><span
|
212
|
+
class="method-args">()</span>
|
213
|
+
<span class="method-click-advice">click to toggle source</span>
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
<div class="method-description">
|
218
|
+
|
219
|
+
<p>
|
220
|
+
Constructor. Initializes the following:
|
221
|
+
</p>
|
222
|
+
<ul>
|
223
|
+
<li><p>
|
224
|
+
url is set to nil
|
225
|
+
</p>
|
226
|
+
</li>
|
227
|
+
<li><p>
|
228
|
+
institution name
|
229
|
+
</p>
|
230
|
+
</li>
|
231
|
+
<li><p>
|
232
|
+
a list of currency codes available from that source
|
233
|
+
</p>
|
234
|
+
</li>
|
235
|
+
<li><p>
|
236
|
+
<a href="DnbNord.html#session_no">session_no</a> number of the session.
|
237
|
+
There are two sessions. 1 means the first at 8:15 am and 2 means the second
|
238
|
+
one held at 12:15
|
239
|
+
</p>
|
240
|
+
</li>
|
241
|
+
</ul>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
<div class="method-source-code"
|
246
|
+
id="new-source">
|
247
|
+
<pre>
|
248
|
+
<span class="ruby-comment cmt"># File lib/currency_spy/dnb_nord.rb, line 12</span>
|
249
|
+
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
250
|
+
13: <span class="ruby-keyword kw">super</span>
|
251
|
+
14: <span class="ruby-ivar">@url</span> = <span class="ruby-keyword kw">nil</span>
|
252
|
+
15: <span class="ruby-ivar">@institution</span> = <span class="ruby-value str">'DnB Nord'</span>
|
253
|
+
16: <span class="ruby-ivar">@available_codes</span> = <span class="ruby-node">%(EUR USD GBP CHF DKK NOK SEK CZK JPY HUF CAD AUD LTL)</span>
|
254
|
+
17: <span class="ruby-ivar">@session_no</span> = <span class="ruby-keyword kw">nil</span>
|
255
|
+
18: <span class="ruby-keyword kw">end</span></pre>
|
256
|
+
</div>
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
</div>
|
264
|
+
|
265
|
+
|
266
|
+
</div>
|
267
|
+
|
268
|
+
<div id="public-instance-method-details" class="method-section section">
|
269
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
270
|
+
|
271
|
+
|
272
|
+
<div id="buy-rate-method" class="method-detail ">
|
273
|
+
<a name="method-i-buy_rate"></a>
|
274
|
+
|
275
|
+
<div class="method-heading">
|
276
|
+
|
277
|
+
<span class="method-name">buy_rate</span><span
|
278
|
+
class="method-args">()</span>
|
279
|
+
<span class="method-click-advice">click to toggle source</span>
|
280
|
+
|
281
|
+
</div>
|
282
|
+
|
283
|
+
<div class="method-description">
|
284
|
+
|
285
|
+
<p>
|
286
|
+
Fetches the buying rate
|
287
|
+
</p>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
<div class="method-source-code"
|
292
|
+
id="buy-rate-source">
|
293
|
+
<pre>
|
294
|
+
<span class="ruby-comment cmt"># File lib/currency_spy/dnb_nord.rb, line 40</span>
|
295
|
+
40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">buy_rate</span>
|
296
|
+
41: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">currency_code</span>)
|
297
|
+
42: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">nil</span>
|
298
|
+
43: <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">"//td"</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">td</span><span class="ruby-operator">|</span>
|
299
|
+
44: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">td</span>.<span class="ruby-identifier">content</span>))
|
300
|
+
45: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">td</span>.<span class="ruby-identifier">next_element</span>.<span class="ruby-identifier">content</span>.<span class="ruby-identifier">to_f</span>
|
301
|
+
46: <span class="ruby-keyword kw">end</span>
|
302
|
+
47: <span class="ruby-keyword kw">end</span>
|
303
|
+
48: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>
|
304
|
+
49: <span class="ruby-keyword kw">end</span></pre>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
</div>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
</div>
|
313
|
+
|
314
|
+
|
315
|
+
<div id="rate-time-method" class="method-detail ">
|
316
|
+
<a name="method-i-rate_time"></a>
|
317
|
+
|
318
|
+
<div class="method-heading">
|
319
|
+
|
320
|
+
<span class="method-name">rate_time</span><span
|
321
|
+
class="method-args">()</span>
|
322
|
+
<span class="method-click-advice">click to toggle source</span>
|
323
|
+
|
324
|
+
</div>
|
325
|
+
|
326
|
+
<div class="method-description">
|
327
|
+
|
328
|
+
<p>
|
329
|
+
Fetches the time of given rates
|
330
|
+
</p>
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
<div class="method-source-code"
|
335
|
+
id="rate-time-source">
|
336
|
+
<pre>
|
337
|
+
<span class="ruby-comment cmt"># File lib/currency_spy/dnb_nord.rb, line 52</span>
|
338
|
+
52: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rate_time</span>
|
339
|
+
53: <span class="ruby-identifier">hour</span> = <span class="ruby-ivar">@session_time</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-operator">?</span> <span class="ruby-value str">"12:15"</span> <span class="ruby-operator">:</span> <span class="ruby-value str">"08:15"</span>
|
340
|
+
54: <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">hour</span>)
|
341
|
+
55: <span class="ruby-keyword kw">end</span></pre>
|
342
|
+
</div>
|
343
|
+
|
344
|
+
</div>
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
|
352
|
+
<div id="sell-rate-method" class="method-detail ">
|
353
|
+
<a name="method-i-sell_rate"></a>
|
354
|
+
|
355
|
+
<div class="method-heading">
|
356
|
+
|
357
|
+
<span class="method-name">sell_rate</span><span
|
358
|
+
class="method-args">()</span>
|
359
|
+
<span class="method-click-advice">click to toggle source</span>
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
<div class="method-description">
|
364
|
+
|
365
|
+
<p>
|
366
|
+
Fetches the selling rate
|
367
|
+
</p>
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
<div class="method-source-code"
|
372
|
+
id="sell-rate-source">
|
373
|
+
<pre>
|
374
|
+
<span class="ruby-comment cmt"># File lib/currency_spy/dnb_nord.rb, line 28</span>
|
375
|
+
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sell_rate</span>
|
376
|
+
29: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">currency_code</span>)
|
377
|
+
30: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">nil</span>
|
378
|
+
31: <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">"//td"</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">td</span><span class="ruby-operator">|</span>
|
379
|
+
32: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">td</span>.<span class="ruby-identifier">content</span>))
|
380
|
+
33: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">td</span>.<span class="ruby-identifier">next_element</span>.<span class="ruby-identifier">next_element</span>.<span class="ruby-identifier">content</span>.<span class="ruby-identifier">to_f</span>
|
381
|
+
34: <span class="ruby-keyword kw">end</span>
|
382
|
+
35: <span class="ruby-keyword kw">end</span>
|
383
|
+
36: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>
|
384
|
+
37: <span class="ruby-keyword kw">end</span></pre>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
394
|
+
|
395
|
+
<div id="url-method" class="method-detail ">
|
396
|
+
<a name="method-i-url"></a>
|
397
|
+
|
398
|
+
<div class="method-heading">
|
399
|
+
|
400
|
+
<span class="method-name">url</span><span
|
401
|
+
class="method-args">()</span>
|
402
|
+
<span class="method-click-advice">click to toggle source</span>
|
403
|
+
|
404
|
+
</div>
|
405
|
+
|
406
|
+
<div class="method-description">
|
407
|
+
|
408
|
+
<p>
|
409
|
+
Determines the correct url of the web page to fetch rates from based of the
|
410
|
+
instance variable <a href="DnbNord.html#session_no">session_no</a>
|
411
|
+
</p>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
<div class="method-source-code"
|
416
|
+
id="url-source">
|
417
|
+
<pre>
|
418
|
+
<span class="ruby-comment cmt"># File lib/currency_spy/dnb_nord.rb, line 21</span>
|
419
|
+
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">url</span>
|
420
|
+
22: <span class="ruby-identifier">dnb_session_no</span> = <span class="ruby-ivar">@session_no</span> <span class="ruby-operator">||=</span> <span class="ruby-value">1</span>
|
421
|
+
23: <span class="ruby-identifier">session_time</span> = <span class="ruby-identifier">dnb_session_no</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-operator">?</span> <span class="ruby-value str">"12:15"</span> <span class="ruby-operator">:</span> <span class="ruby-value str">"08:15"</span>
|
422
|
+
24: <span class="ruby-keyword kw">return</span> <span class="ruby-node">"http://www.dnbnord.pl/pl/tabela-kursow-walut-dla-kredytow/go:godzina=#{session_time}"</span>
|
423
|
+
25: <span class="ruby-keyword kw">end</span></pre>
|
424
|
+
</div>
|
425
|
+
|
426
|
+
</div>
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
</div>
|
432
|
+
|
433
|
+
|
434
|
+
</div>
|
435
|
+
|
436
|
+
|
437
|
+
</div>
|
438
|
+
|
439
|
+
|
440
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
441
|
+
|
442
|
+
<p>Disabled; run with --debug to generate this.</p>
|
443
|
+
|
444
|
+
</div>
|
445
|
+
|
446
|
+
<div id="validator-badges">
|
447
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
448
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
449
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
450
|
+
</div>
|
451
|
+
|
452
|
+
</body>
|
453
|
+
</html>
|
454
|
+
|