bond_calculator 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +7 -0
  7. data/README.md +78 -0
  8. data/Rakefile +13 -0
  9. data/bin/console +10 -0
  10. data/bond_calculator.gemspec +30 -0
  11. data/doc/BondCalculator.html +140 -0
  12. data/doc/BondCalculator/BaseCalculator.html +480 -0
  13. data/doc/BondCalculator/Bond.html +693 -0
  14. data/doc/BondCalculator/SpreadToBenchmark.html +567 -0
  15. data/doc/BondCalculator/SpreadToCurve.html +475 -0
  16. data/doc/_index.html +143 -0
  17. data/doc/class_list.html +51 -0
  18. data/doc/css/common.css +1 -0
  19. data/doc/css/full_list.css +58 -0
  20. data/doc/css/style.css +492 -0
  21. data/doc/file.README.html +133 -0
  22. data/doc/file_list.html +56 -0
  23. data/doc/frames.html +17 -0
  24. data/doc/index.html +133 -0
  25. data/doc/js/app.js +248 -0
  26. data/doc/js/full_list.js +216 -0
  27. data/doc/js/jquery.js +4 -0
  28. data/doc/method_list.html +155 -0
  29. data/doc/top-level-namespace.html +110 -0
  30. data/lib/bond_calculator.rb +7 -0
  31. data/lib/bond_calculator/base_calculator.rb +37 -0
  32. data/lib/bond_calculator/bond.rb +48 -0
  33. data/lib/bond_calculator/spread_to_benchmark.rb +77 -0
  34. data/lib/bond_calculator/spread_to_curve.rb +64 -0
  35. data/lib/bond_calculator/version.rb +5 -0
  36. data/test/bond_calculator/base_calculator_test.rb +31 -0
  37. data/test/bond_calculator/bond_calculator_test.rb +9 -0
  38. data/test/bond_calculator/bond_test.rb +24 -0
  39. data/test/bond_calculator/spread_to_benchmark_test.rb +33 -0
  40. data/test/bond_calculator/spread_to_curve_test.rb +37 -0
  41. data/test/fixtures/c1.csv +4 -0
  42. data/test/fixtures/c2.csv +14 -0
  43. data/test/test_helper.rb +7 -0
  44. metadata +191 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e3d9329d240806ff26b35738bdf537517ce44cbc
4
+ data.tar.gz: b814f31955b738655d54e674f9b5f3a6c7afecdc
5
+ SHA512:
6
+ metadata.gz: a8c5cf3c320a41dfe214ab78f37f5d0d732994b04fa0dc57240034d07581ea1dc616c5ba0a4675350af33f4ff837f439c9cdb5d4742069689ed38dbf0a4d4a6c
7
+ data.tar.gz: 0a8ffc450e7599d9775ae14acec2100b3c498d826b33fdccbebdb38fb04bac3c1d69a7de978ac0ab3c8e3b8a23d2e13ad002c3a6aaa613c55b4c5b68f0673100
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/bundle
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
16
+ .idea/*
17
+ .DS_Store
@@ -0,0 +1 @@
1
+ 2.4.0
@@ -0,0 +1,5 @@
1
+ # Bond Calculator
2
+
3
+ ## Version 0.0.1 (25/09/2017)
4
+ * Initial Development of the best bond calculator
5
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in bond_calculator.gemspec
6
+ gemspec
@@ -0,0 +1,7 @@
1
+ Copyright 2017 Lucas Sant' Anna
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ # bond_calculator
2
+ Bond Calculator is a ruby gem that helps calculate spread-to-benchmark
3
+ and spread-to-curve
4
+
5
+ ## Installation
6
+
7
+ **bond_calculator**'s installation is pretty standard:
8
+
9
+ ```sh
10
+ $ gem install bond_calculator
11
+ ```
12
+ ## Compatibility
13
+
14
+ bond_calculator supports the following Ruby versions:
15
+
16
+ * 2.3
17
+ * 2.4
18
+
19
+ ## Test
20
+
21
+ ```sh
22
+ $ git clone https://github.com/lucassantanna/bond_calculator
23
+ $ cd bond_calculator
24
+ $ rake
25
+ ```
26
+
27
+ ## Quickstart
28
+
29
+ ```sh
30
+ $ cd ~/Desktop
31
+ $ git clone https://github.com/lucassantanna/bond_calculator
32
+ $ mkdir bond_example
33
+
34
+ $ cd bond_example
35
+ $ wget https://raw.githubusercontent.com/lucassantanna/bond_calculator/master/test/fixtures/c1.csv
36
+ $ wget https://raw.githubusercontent.com/lucassantanna/bond_calculator/master/test/fixtures/c2.csv
37
+
38
+ $ cd ~/Desktop/bond_calculator
39
+ $ /bin/console
40
+ ```
41
+
42
+ ```ruby
43
+ # to calculate spread to benchmark
44
+ > BondCalculator::SpreadToBenchmark.new('PATH_TO_DESKTOP/bond_example/c1.csv').calculate
45
+
46
+ # OUTPUT:
47
+ # bond, benchmark, spread_to_benchmark
48
+ # C1, G1, 1.6
49
+ # => [{:bond_name=>"C1", :benchmark_name=>"G1", :spread_to_benchmark=>1.6}]
50
+
51
+ # to calculate spread to curve
52
+ > BondCalculator::SpreadToCurve.new('PATH_TO_DESKTOP/bond_example/c2.csv').calculate
53
+
54
+ # OUTPUT:
55
+ # bond, spread to curve
56
+ # C1, 1.43
57
+ # C2, 1.63
58
+ # C3, 2.47
59
+ # C4, 2.27
60
+ # C5, 1.9
61
+ # C6, 1.57
62
+ # C7, 2.83
63
+ # => [{:bond_name=>"C1", :spread_to_curve=>1.43}, {:bond_name=>"C2", :spread_to_curve=>1.63}, {:bond_name=>"C3", # :spread_to_curve=>2.47},{:bond_name=>"C4", :spread_to_curve=>2.27}, {:bond_name=>"C5", :spread_to_curve=>1.9}, # {:bond_name=>"C6", :spread_to_curve=>1.57}, {:bond
64
+ # _name=>"C7", :spread_to_curve=>2.83}]
65
+
66
+ ```
67
+ ## Technical spec
68
+ * Ruby 2.4.0
69
+ * bundler ( Manage the gems that the application depends on)
70
+ * mini-test ( I' ve decided to use mini-test because I have some experience with rspec but no experience with mini-test )
71
+ * rake ( Created a task to run the tests )
72
+ * pry ( debugging )
73
+ * rubocop ( guarantee that the code is following the best practices)
74
+ * YARD (Generate beautiful documentation.)
75
+
76
+ ## License
77
+
78
+ The gem is available under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |test|
7
+ test.libs << 'lib' << 'test'
8
+ test.pattern = 'test/**/*_test.rb'
9
+ test.verbose = true
10
+ end
11
+
12
+ desc 'Run tests'
13
+ task default: :test
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'bond_calculator'
6
+ require 'time'
7
+ require 'irb'
8
+ require 'pry'
9
+
10
+ IRB.start
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'bond_calculator/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'bond_calculator'
9
+ spec.version = BondCalculator::VERSION
10
+ spec.authors = ['Lucas Sant Anna']
11
+ spec.email = ['l.minota@gmail.com']
12
+ spec.summary = 'Ruby Best Bond Calculator'
13
+ spec.description = 'Calculate the best bond'
14
+ spec.homepage = 'http://lucassantanna.com'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = ['>= 2.4.0']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.7'
25
+ spec.add_development_dependency 'minitest-reporters', '~> 1.1', '>= 1.1.13'
26
+ spec.add_development_dependency 'minitest', '~> 5.8', '>= 5.8.4'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'rubocop', '~> 0.50.0'
30
+ end
@@ -0,0 +1,140 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: BondCalculator
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "BondCalculator";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (B)</a> &raquo;
40
+
41
+
42
+ <span class="title">BondCalculator</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: BondCalculator
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/bond_calculator/bond.rb<span class="defines">,<br />
82
+ lib/bond_calculator/version.rb,<br /> lib/bond_calculator/base_calculator.rb,<br /> lib/bond_calculator/spread_to_curve.rb,<br /> lib/bond_calculator/spread_to_benchmark.rb</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Overview</h2><div class="docstring">
89
+ <div class="discussion">
90
+
91
+ <p>Namespace for classes and modules that handle Bond calculation</p>
92
+
93
+ <pre class="code ruby"><code class="ruby">@since 0.0.1</code></pre>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div><h2>Defined Under Namespace</h2>
102
+ <p class="children">
103
+
104
+
105
+
106
+
107
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="BondCalculator/BaseCalculator.html" title="BondCalculator::BaseCalculator (class)">BaseCalculator</a></span>, <span class='object_link'><a href="BondCalculator/Bond.html" title="BondCalculator::Bond (class)">Bond</a></span>, <span class='object_link'><a href="BondCalculator/SpreadToBenchmark.html" title="BondCalculator::SpreadToBenchmark (class)">SpreadToBenchmark</a></span>, <span class='object_link'><a href="BondCalculator/SpreadToCurve.html" title="BondCalculator::SpreadToCurve (class)">SpreadToCurve</a></span>
108
+
109
+
110
+ </p>
111
+
112
+ <h2>Constant Summary</h2>
113
+ <dl class="constants">
114
+
115
+ <dt id="VERSION-constant" class="">VERSION =
116
+
117
+ </dt>
118
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.0.1</span><span class='tstring_end'>&#39;</span></span></pre></dd>
119
+
120
+ </dl>
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ </div>
131
+
132
+ <div id="footer">
133
+ Generated on Mon Sep 25 23:31:15 2017 by
134
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
135
+ 0.9.9 (ruby-2.4.0).
136
+ </div>
137
+
138
+ </div>
139
+ </body>
140
+ </html>
@@ -0,0 +1,480 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: BondCalculator::BaseCalculator
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "BondCalculator::BaseCalculator";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../BondCalculator.html" title="BondCalculator (module)">BondCalculator</a></span></span>
41
+ &raquo;
42
+ <span class="title">BaseCalculator</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: BondCalculator::BaseCalculator
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">BondCalculator::BaseCalculator</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/bond_calculator/base_calculator.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Abstract base class for Bond Calculation. Provides some helper methods for
106
+ convert the csv file to a bond map and a filter for the bonds collection</p>
107
+
108
+
109
+ </div>
110
+ </div>
111
+ <div class="tags">
112
+
113
+ <p class="tag_title">Author:</p>
114
+ <ul class="author">
115
+
116
+ <li>
117
+
118
+
119
+
120
+
121
+
122
+ <div class='inline'>
123
+ <p>Lucas Sant&#39; Anna</p>
124
+ </div>
125
+
126
+ </li>
127
+
128
+ </ul>
129
+ <p class="tag_title">Since:</p>
130
+ <ul class="since">
131
+
132
+ <li>
133
+
134
+
135
+
136
+
137
+
138
+ <div class='inline'>
139
+ <p>0.0.1</p>
140
+ </div>
141
+
142
+ </li>
143
+
144
+ </ul>
145
+
146
+ </div><div id="subclasses">
147
+ <h2>Direct Known Subclasses</h2>
148
+ <p class="children"><span class='object_link'><a href="SpreadToBenchmark.html" title="BondCalculator::SpreadToBenchmark (class)">SpreadToBenchmark</a></span>, <span class='object_link'><a href="SpreadToCurve.html" title="BondCalculator::SpreadToCurve (class)">SpreadToCurve</a></span></p>
149
+ </div>
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ <h2>
159
+ Instance Method Summary
160
+ <small><a href="#" class="summary_toggle">collapse</a></small>
161
+ </h2>
162
+
163
+ <ul class="summary">
164
+
165
+ <li class="public ">
166
+ <span class="summary_signature">
167
+
168
+ <a href="#bonds_by_type-instance_method" title="#bonds_by_type (instance method)">#<strong>bonds_by_type</strong>(type, bonds) &#x21d2; Array&lt;Bond&gt; </a>
169
+
170
+
171
+
172
+ </span>
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+ <span class="summary_desc"><div class='inline'>
183
+ <p>filter bond list by type.</p>
184
+ </div></span>
185
+
186
+ </li>
187
+
188
+
189
+ <li class="public ">
190
+ <span class="summary_signature">
191
+
192
+ <a href="#csv_to_bonds-instance_method" title="#csv_to_bonds (instance method)">#<strong>csv_to_bonds</strong>(csv_path) &#x21d2; Array&lt;Bond&gt; </a>
193
+
194
+
195
+
196
+ </span>
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+ <span class="summary_desc"><div class='inline'>
207
+ <p>convert a csv file to a Bond list.</p>
208
+ </div></span>
209
+
210
+ </li>
211
+
212
+
213
+ </ul>
214
+
215
+
216
+
217
+
218
+ <div id="instance_method_details" class="method_details_list">
219
+ <h2>Instance Method Details</h2>
220
+
221
+
222
+ <div class="method_details first">
223
+ <h3 class="signature first" id="bonds_by_type-instance_method">
224
+
225
+ #<strong>bonds_by_type</strong>(type, bonds) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Bond.html" title="BondCalculator::Bond (class)">Bond</a></span>&gt;</tt>
226
+
227
+
228
+
229
+
230
+
231
+ </h3><div class="docstring">
232
+ <div class="discussion">
233
+
234
+ <p>filter bond list by type</p>
235
+
236
+
237
+ </div>
238
+ </div>
239
+ <div class="tags">
240
+ <p class="tag_title">Parameters:</p>
241
+ <ul class="param">
242
+
243
+ <li>
244
+
245
+ <span class='name'>type</span>
246
+
247
+
248
+ <span class='type'>(<tt>String</tt>)</span>
249
+
250
+
251
+
252
+ &mdash;
253
+ <div class='inline'>
254
+ <p>it is possible to search by any type eg:&#39;corporate&#39; or
255
+ &#39;government&#39;</p>
256
+ </div>
257
+
258
+ </li>
259
+
260
+ <li>
261
+
262
+ <span class='name'>bonds</span>
263
+
264
+
265
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Bond.html" title="BondCalculator::Bond (class)">Bond</a></span>&gt;</tt>)</span>
266
+
267
+
268
+
269
+ &mdash;
270
+ <div class='inline'>
271
+ <p>Bond list</p>
272
+ </div>
273
+
274
+ </li>
275
+
276
+ </ul>
277
+
278
+ <p class="tag_title">Returns:</p>
279
+ <ul class="return">
280
+
281
+ <li>
282
+
283
+
284
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Bond.html" title="BondCalculator::Bond (class)">Bond</a></span>&gt;</tt>)</span>
285
+
286
+
287
+
288
+ &mdash;
289
+ <div class='inline'>
290
+ <p>bond list with the filterd type</p>
291
+ </div>
292
+
293
+ </li>
294
+
295
+ </ul>
296
+ <p class="tag_title">Author:</p>
297
+ <ul class="author">
298
+
299
+ <li>
300
+
301
+
302
+
303
+
304
+
305
+ <div class='inline'>
306
+ <p>Lucas Sant&#39; Anna</p>
307
+ </div>
308
+
309
+ </li>
310
+
311
+ </ul>
312
+ <p class="tag_title">Since:</p>
313
+ <ul class="since">
314
+
315
+ <li>
316
+
317
+
318
+
319
+
320
+
321
+ <div class='inline'>
322
+ <p>0.0.1</p>
323
+ </div>
324
+
325
+ </li>
326
+
327
+ </ul>
328
+
329
+ </div><table class="source_code">
330
+ <tr>
331
+ <td>
332
+ <pre class="lines">
333
+
334
+
335
+ 30
336
+ 31
337
+ 32
338
+ 33
339
+ 34
340
+ 35</pre>
341
+ </td>
342
+ <td>
343
+ <pre class="code"><span class="info file"># File 'lib/bond_calculator/base_calculator.rb', line 30</span>
344
+
345
+ <span class='kw'>def</span> <span class='id identifier rubyid_bonds_by_type'>bonds_by_type</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_bonds'>bonds</span><span class='rparen'>)</span>
346
+ <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_bonds'>bonds</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
347
+
348
+ <span class='id identifier rubyid_bonds'>bonds</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_bond'>bond</span><span class='op'>|</span> <span class='id identifier rubyid_bond'>bond</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='id identifier rubyid_type'>type</span> <span class='rbrace'>}</span>
349
+ <span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_bond'>bond</span><span class='op'>|</span> <span class='id identifier rubyid_bond'>bond</span><span class='period'>.</span><span class='id identifier rubyid_term_years'>term_years</span> <span class='rbrace'>}</span>
350
+ <span class='kw'>end</span></pre>
351
+ </td>
352
+ </tr>
353
+ </table>
354
+ </div>
355
+
356
+ <div class="method_details ">
357
+ <h3 class="signature " id="csv_to_bonds-instance_method">
358
+
359
+ #<strong>csv_to_bonds</strong>(csv_path) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Bond.html" title="BondCalculator::Bond (class)">Bond</a></span>&gt;</tt>
360
+
361
+
362
+
363
+
364
+
365
+ </h3><div class="docstring">
366
+ <div class="discussion">
367
+
368
+ <p>convert a csv file to a Bond list</p>
369
+
370
+
371
+ </div>
372
+ </div>
373
+ <div class="tags">
374
+ <p class="tag_title">Parameters:</p>
375
+ <ul class="param">
376
+
377
+ <li>
378
+
379
+ <span class='name'>csv_path</span>
380
+
381
+
382
+ <span class='type'>(<tt>file_path</tt>)</span>
383
+
384
+
385
+
386
+ &mdash;
387
+ <div class='inline'>
388
+ <p>Any file with the the bond&#39;s csv header structure</p>
389
+ </div>
390
+
391
+ </li>
392
+
393
+ </ul>
394
+
395
+ <p class="tag_title">Returns:</p>
396
+ <ul class="return">
397
+
398
+ <li>
399
+
400
+
401
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Bond.html" title="BondCalculator::Bond (class)">Bond</a></span>&gt;</tt>)</span>
402
+
403
+
404
+
405
+ </li>
406
+
407
+ </ul>
408
+ <p class="tag_title">Author:</p>
409
+ <ul class="author">
410
+
411
+ <li>
412
+
413
+
414
+
415
+
416
+
417
+ <div class='inline'>
418
+ <p>Lucas Sant&#39; Anna</p>
419
+ </div>
420
+
421
+ </li>
422
+
423
+ </ul>
424
+ <p class="tag_title">Since:</p>
425
+ <ul class="since">
426
+
427
+ <li>
428
+
429
+
430
+
431
+
432
+
433
+ <div class='inline'>
434
+ <p>0.0.1</p>
435
+ </div>
436
+
437
+ </li>
438
+
439
+ </ul>
440
+
441
+ </div><table class="source_code">
442
+ <tr>
443
+ <td>
444
+ <pre class="lines">
445
+
446
+
447
+ 18
448
+ 19
449
+ 20
450
+ 21
451
+ 22
452
+ 23</pre>
453
+ </td>
454
+ <td>
455
+ <pre class="code"><span class="info file"># File 'lib/bond_calculator/base_calculator.rb', line 18</span>
456
+
457
+ <span class='kw'>def</span> <span class='id identifier rubyid_csv_to_bonds'>csv_to_bonds</span><span class='lparen'>(</span><span class='id identifier rubyid_csv_path'>csv_path</span><span class='rparen'>)</span>
458
+ <span class='id identifier rubyid_csv'>csv</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_csv_path'>csv_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
459
+ <span class='id identifier rubyid_bonds_csv'>bonds_csv</span> <span class='op'>=</span> <span class='const'>CSV</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_csv'>csv</span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_h</span><span class='rparen'>)</span>
460
+ <span class='id identifier rubyid_csv'>csv</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
461
+ <span class='id identifier rubyid_bonds_csv'>bonds_csv</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="Bond.html" title="BondCalculator::Bond (class)">Bond</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Bond.html#initialize-instance_method" title="BondCalculator::Bond#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_line'>line</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
462
+ <span class='kw'>end</span></pre>
463
+ </td>
464
+ </tr>
465
+ </table>
466
+ </div>
467
+
468
+ </div>
469
+
470
+ </div>
471
+
472
+ <div id="footer">
473
+ Generated on Mon Sep 25 23:31:15 2017 by
474
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
475
+ 0.9.9 (ruby-2.4.0).
476
+ </div>
477
+
478
+ </div>
479
+ </body>
480
+ </html>