student_mvp 0.1.8 → 0.1.10
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.
- checksums.yaml +4 -4
- data/doc/App_logger.html +47 -33
- data/doc/DB_client.html +20 -10
- data/doc/created.rid +10 -44
- data/doc/index.html +2 -81
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +9 -697
- data/lib/data_access/DB_client/DB_client.rb +20 -1
- data/lib/logger/logger.rb +35 -0
- data/lib/presenters/base_presenters/student_list_presenter.rb +1 -1
- data/lib/student_mvp/version.rb +1 -1
- metadata +56 -35
- data/doc/Binary_tree.html +0 -300
- data/doc/Binary_tree_iterator.html +0 -217
- data/doc/Contact_sort_decorator.html +0 -219
- data/doc/Data_list.html +0 -625
- data/doc/Data_list_student_short.html +0 -148
- data/doc/Data_storage_strategy.html +0 -178
- data/doc/Data_table.html +0 -264
- data/doc/Deep_dup.html +0 -152
- data/doc/Field_filter_decorator.html +0 -219
- data/doc/Filter.html +0 -148
- data/doc/Filter_decorator.html +0 -209
- data/doc/Full_name_filter_decorator.html +0 -211
- data/doc/Full_name_sort_decorator.html +0 -217
- data/doc/Gemfile.html +0 -98
- data/doc/Git_sort_decorator.html +0 -220
- data/doc/Has_not_field_filter_decorator.html +0 -209
- data/doc/JSON_storage_strategy.html +0 -183
- data/doc/Person.html +0 -511
- data/doc/README_md.html +0 -147
- data/doc/Rakefile.html +0 -94
- data/doc/Sort_decorator.html +0 -214
- data/doc/Student.html +0 -755
- data/doc/StudentMvp/Error.html +0 -105
- data/doc/StudentMvp.html +0 -111
- data/doc/Student_short.html +0 -398
- data/doc/Students_list.html +0 -341
- data/doc/Students_list_DB.html +0 -361
- data/doc/Students_list_file.html +0 -460
- data/doc/Students_list_file_adapter.html +0 -341
- data/doc/Students_list_interface.html +0 -298
- data/doc/YAML_storage_strategy.html +0 -183
- data/doc/bin/setup.html +0 -96
data/doc/Students_list_file.html
DELETED
@@ -1,460 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
7
|
-
|
8
|
-
<title>class Students_list_file - RDoc Documentation</title>
|
9
|
-
|
10
|
-
<meta name="keywords" content="ruby,class,Students_list_file">
|
11
|
-
|
12
|
-
<meta name="description" content="Documentation for the Students_list_file class">
|
13
|
-
|
14
|
-
<script type="text/javascript">
|
15
|
-
var rdoc_rel_prefix = "./";
|
16
|
-
var index_rel_prefix = "./";
|
17
|
-
</script>
|
18
|
-
|
19
|
-
<script src="./js/navigation.js" defer></script>
|
20
|
-
<script src="./js/search.js" defer></script>
|
21
|
-
<script src="./js/search_index.js" defer></script>
|
22
|
-
<script src="./js/searcher.js" defer></script>
|
23
|
-
<script src="./js/darkfish.js" defer></script>
|
24
|
-
|
25
|
-
<link href="./css/fonts.css" rel="stylesheet">
|
26
|
-
<link href="./css/rdoc.css" rel="stylesheet">
|
27
|
-
|
28
|
-
|
29
|
-
<body id="top" role="document" class="class">
|
30
|
-
<div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
|
31
|
-
<span aria-hidden="true">☰</span>
|
32
|
-
</div>
|
33
|
-
|
34
|
-
|
35
|
-
<nav id="navigation" role="navigation">
|
36
|
-
<div id="project-navigation">
|
37
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
38
|
-
<h2>
|
39
|
-
<a href="./index.html" rel="home">Home</a>
|
40
|
-
</h2>
|
41
|
-
|
42
|
-
<div id="table-of-contents-navigation">
|
43
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
44
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
45
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
|
49
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
50
|
-
<form action="#" method="get" accept-charset="utf-8">
|
51
|
-
<div id="search-field-wrapper">
|
52
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
53
|
-
aria-autocomplete="list" aria-controls="search-results"
|
54
|
-
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
55
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
56
|
-
</div>
|
57
|
-
|
58
|
-
<ul id="search-results" aria-label="Search Results"
|
59
|
-
aria-busy="false" aria-expanded="false"
|
60
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
61
|
-
</form>
|
62
|
-
</div>
|
63
|
-
|
64
|
-
</div>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
<div id="parent-class-section" class="nav-section">
|
69
|
-
<h3>Ancestors</h3>
|
70
|
-
<ul><li><a href="Students_list_interface.html">Students_list_interface</a><ul><li>Object</li></ul></li></ul>
|
71
|
-
</div>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
<div class="nav-section">
|
77
|
-
<h3>Class Methods</h3>
|
78
|
-
<ul class="link-list" role="directory">
|
79
|
-
<li ><a href="#method-c-new">new</a></li>
|
80
|
-
</ul>
|
81
|
-
</div>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
<div class="nav-section">
|
86
|
-
<h3>Instance Methods</h3>
|
87
|
-
<ul class="link-list" role="directory">
|
88
|
-
<li ><a href="#method-i-add_student">add_student</a></li>
|
89
|
-
<li ><a href="#method-i-delete_student">delete_student</a></li>
|
90
|
-
<li ><a href="#method-i-get_k_n_student_short_list">get_k_n_student_short_list</a></li>
|
91
|
-
<li ><a href="#method-i-get_student_by_id">get_student_by_id</a></li>
|
92
|
-
<li ><a href="#method-i-get_student_short_count">get_student_short_count</a></li>
|
93
|
-
<li ><a href="#method-i-read">read</a></li>
|
94
|
-
<li ><a href="#method-i-replace_student">replace_student</a></li>
|
95
|
-
<li ><a href="#method-i-sort_by_full_name-21">sort_by_full_name!</a></li>
|
96
|
-
<li ><a href="#method-i-write">write</a></li>
|
97
|
-
</ul>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
<footer id="validator-badges" role="contentinfo">
|
103
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
104
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.8.1.
|
105
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
106
|
-
</footer>
|
107
|
-
|
108
|
-
</nav>
|
109
|
-
|
110
|
-
<main role="main" aria-labelledby="class-Students_list_file">
|
111
|
-
<h1 id="class-Students_list_file" class="anchor-link class">
|
112
|
-
class Students_list_file
|
113
|
-
</h1>
|
114
|
-
|
115
|
-
<section class="description">
|
116
|
-
|
117
|
-
</section>
|
118
|
-
|
119
|
-
<section id="5Buntitled-5D" class="documentation-section anchor-link">
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
|
126
|
-
<header>
|
127
|
-
<h3>Public Class Methods</h3>
|
128
|
-
</header>
|
129
|
-
|
130
|
-
<div id="method-c-new" class="method-detail anchor-link ">
|
131
|
-
<div class="method-header">
|
132
|
-
<div class="method-heading">
|
133
|
-
<a href="#method-c-new" title="Link to this method">
|
134
|
-
<span class="method-name">new</span>
|
135
|
-
<span class="method-args">(file_path, data_storage_strategy)</span>
|
136
|
-
</a>
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
|
140
|
-
<div class="method-controls">
|
141
|
-
<details class="method-source-toggle">
|
142
|
-
<summary>Source</summary>
|
143
|
-
</details>
|
144
|
-
</div>
|
145
|
-
|
146
|
-
<div class="method-description">
|
147
|
-
<div class="method-source-code" id="new-source">
|
148
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 9</span>
|
149
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">file_path</span>, <span class="ruby-identifier">data_storage_strategy</span>)
|
150
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">file_path</span> = <span class="ruby-identifier">file_path</span>
|
151
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">data_storage_strategy</span> = <span class="ruby-identifier">data_storage_strategy</span>
|
152
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span> = <span class="ruby-identifier">read</span>
|
153
|
-
<span class="ruby-keyword">end</span></pre>
|
154
|
-
</div>
|
155
|
-
<p>constructor</p>
|
156
|
-
</div>
|
157
|
-
|
158
|
-
|
159
|
-
</div>
|
160
|
-
|
161
|
-
</section>
|
162
|
-
|
163
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
|
164
|
-
<header>
|
165
|
-
<h3>Public Instance Methods</h3>
|
166
|
-
</header>
|
167
|
-
|
168
|
-
<div id="method-i-add_student" class="method-detail anchor-link ">
|
169
|
-
<div class="method-header">
|
170
|
-
<div class="method-heading">
|
171
|
-
<a href="#method-i-add_student" title="Link to this method">
|
172
|
-
<span class="method-name">add_student</span>
|
173
|
-
<span class="method-args">(student)</span>
|
174
|
-
</a>
|
175
|
-
</div>
|
176
|
-
</div>
|
177
|
-
|
178
|
-
<div class="method-controls">
|
179
|
-
<details class="method-source-toggle">
|
180
|
-
<summary>Source</summary>
|
181
|
-
</details>
|
182
|
-
</div>
|
183
|
-
|
184
|
-
<div class="method-description">
|
185
|
-
<div class="method-source-code" id="add_student-source">
|
186
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 49</span>
|
187
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_student</span>(<span class="ruby-identifier">student</span>)
|
188
|
-
<span class="ruby-keyword">begin</span>
|
189
|
-
<span class="ruby-identifier">check_unique_fileds</span>(<span class="ruby-value">email:</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">email</span>, <span class="ruby-value">telegram:</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">telegram</span>, <span class="ruby-value">phone_number:</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">phone_number</span>, <span class="ruby-value">git:</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">git</span>)
|
190
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
191
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
192
|
-
<span class="ruby-keyword">end</span>
|
193
|
-
<span class="ruby-identifier">max_id</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&</span><span class="ruby-value">:id</span>).<span class="ruby-identifier">max</span> <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
194
|
-
<span class="ruby-identifier">student</span>.<span class="ruby-identifier">id</span> = <span class="ruby-identifier">max_id</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
195
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">student</span>
|
196
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">write</span>
|
197
|
-
<span class="ruby-keyword">end</span></pre>
|
198
|
-
</div>
|
199
|
-
<p>add student</p>
|
200
|
-
</div>
|
201
|
-
|
202
|
-
|
203
|
-
</div>
|
204
|
-
|
205
|
-
<div id="method-i-delete_student" class="method-detail anchor-link ">
|
206
|
-
<div class="method-header">
|
207
|
-
<div class="method-heading">
|
208
|
-
<a href="#method-i-delete_student" title="Link to this method">
|
209
|
-
<span class="method-name">delete_student</span>
|
210
|
-
<span class="method-args">(id)</span>
|
211
|
-
</a>
|
212
|
-
</div>
|
213
|
-
</div>
|
214
|
-
|
215
|
-
<div class="method-controls">
|
216
|
-
<details class="method-source-toggle">
|
217
|
-
<summary>Source</summary>
|
218
|
-
</details>
|
219
|
-
</div>
|
220
|
-
|
221
|
-
<div class="method-description">
|
222
|
-
<div class="method-source-code" id="delete_student-source">
|
223
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 77</span>
|
224
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_student</span>(<span class="ruby-identifier">id</span>)
|
225
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">student</span><span class="ruby-operator">|</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span> }
|
226
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">write</span>
|
227
|
-
<span class="ruby-keyword">end</span></pre>
|
228
|
-
</div>
|
229
|
-
<p>delete student by id</p>
|
230
|
-
</div>
|
231
|
-
|
232
|
-
|
233
|
-
</div>
|
234
|
-
|
235
|
-
<div id="method-i-get_k_n_student_short_list" class="method-detail anchor-link ">
|
236
|
-
<div class="method-header">
|
237
|
-
<div class="method-heading">
|
238
|
-
<a href="#method-i-get_k_n_student_short_list" title="Link to this method">
|
239
|
-
<span class="method-name">get_k_n_student_short_list</span>
|
240
|
-
<span class="method-args">(k, n, filter = nil, data_list = nil)</span>
|
241
|
-
</a>
|
242
|
-
</div>
|
243
|
-
</div>
|
244
|
-
|
245
|
-
<div class="method-controls">
|
246
|
-
<details class="method-source-toggle">
|
247
|
-
<summary>Source</summary>
|
248
|
-
</details>
|
249
|
-
</div>
|
250
|
-
|
251
|
-
<div class="method-description">
|
252
|
-
<div class="method-source-code" id="get_k_n_student_short_list-source">
|
253
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 31</span>
|
254
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_k_n_student_short_list</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">n</span>, <span class="ruby-identifier">filter</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">data_list</span> = <span class="ruby-keyword">nil</span>)
|
255
|
-
<span class="ruby-identifier">start</span> = (<span class="ruby-identifier">k</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">n</span>
|
256
|
-
<span class="ruby-identifier">filtered</span> = <span class="ruby-identifier">filter</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">apply</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>
|
257
|
-
<span class="ruby-identifier">selected</span> = <span class="ruby-identifier">filtered</span>[<span class="ruby-identifier">start</span>, <span class="ruby-identifier">n</span>] <span class="ruby-operator">||</span> []
|
258
|
-
<span class="ruby-identifier">students_short</span> = <span class="ruby-identifier">selected</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">student</span><span class="ruby-operator">|</span> <span class="ruby-constant">Student_short</span>.<span class="ruby-identifier">new_from_student_obj</span>(<span class="ruby-identifier">student</span>) }
|
259
|
-
<span class="ruby-identifier">data_list</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Data_list_student_short</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">students_short</span>)
|
260
|
-
<span class="ruby-identifier">data_list</span>.<span class="ruby-identifier">index</span> = <span class="ruby-identifier">start</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
261
|
-
<span class="ruby-identifier">data_list</span>.<span class="ruby-identifier">data</span> = <span class="ruby-identifier">students_short</span>
|
262
|
-
<span class="ruby-identifier">data_list</span>
|
263
|
-
<span class="ruby-keyword">end</span></pre>
|
264
|
-
</div>
|
265
|
-
<p>get data_list_student_short of k n students</p>
|
266
|
-
</div>
|
267
|
-
|
268
|
-
|
269
|
-
</div>
|
270
|
-
|
271
|
-
<div id="method-i-get_student_by_id" class="method-detail anchor-link ">
|
272
|
-
<div class="method-header">
|
273
|
-
<div class="method-heading">
|
274
|
-
<a href="#method-i-get_student_by_id" title="Link to this method">
|
275
|
-
<span class="method-name">get_student_by_id</span>
|
276
|
-
<span class="method-args">(id)</span>
|
277
|
-
</a>
|
278
|
-
</div>
|
279
|
-
</div>
|
280
|
-
|
281
|
-
<div class="method-controls">
|
282
|
-
<details class="method-source-toggle">
|
283
|
-
<summary>Source</summary>
|
284
|
-
</details>
|
285
|
-
</div>
|
286
|
-
|
287
|
-
<div class="method-description">
|
288
|
-
<div class="method-source-code" id="get_student_by_id-source">
|
289
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 26</span>
|
290
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_student_by_id</span>(<span class="ruby-identifier">id</span>)
|
291
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">student</span><span class="ruby-operator">|</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span> }
|
292
|
-
<span class="ruby-keyword">end</span></pre>
|
293
|
-
</div>
|
294
|
-
<p>get student by id</p>
|
295
|
-
</div>
|
296
|
-
|
297
|
-
|
298
|
-
</div>
|
299
|
-
|
300
|
-
<div id="method-i-get_student_short_count" class="method-detail anchor-link ">
|
301
|
-
<div class="method-header">
|
302
|
-
<div class="method-heading">
|
303
|
-
<a href="#method-i-get_student_short_count" title="Link to this method">
|
304
|
-
<span class="method-name">get_student_short_count</span>
|
305
|
-
<span class="method-args">(filter = nil)</span>
|
306
|
-
</a>
|
307
|
-
</div>
|
308
|
-
</div>
|
309
|
-
|
310
|
-
<div class="method-controls">
|
311
|
-
<details class="method-source-toggle">
|
312
|
-
<summary>Source</summary>
|
313
|
-
</details>
|
314
|
-
</div>
|
315
|
-
|
316
|
-
<div class="method-description">
|
317
|
-
<div class="method-source-code" id="get_student_short_count-source">
|
318
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 83</span>
|
319
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_student_short_count</span>(<span class="ruby-identifier">filter</span> = <span class="ruby-keyword">nil</span>)
|
320
|
-
<span class="ruby-identifier">filter</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">apply</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>.<span class="ruby-identifier">size</span>
|
321
|
-
<span class="ruby-keyword">end</span></pre>
|
322
|
-
</div>
|
323
|
-
<p>get count of students</p>
|
324
|
-
</div>
|
325
|
-
|
326
|
-
|
327
|
-
</div>
|
328
|
-
|
329
|
-
<div id="method-i-read" class="method-detail anchor-link ">
|
330
|
-
<div class="method-header">
|
331
|
-
<div class="method-heading">
|
332
|
-
<a href="#method-i-read" title="Link to this method">
|
333
|
-
<span class="method-name">read</span>
|
334
|
-
<span class="method-args">()</span>
|
335
|
-
</a>
|
336
|
-
</div>
|
337
|
-
</div>
|
338
|
-
|
339
|
-
<div class="method-controls">
|
340
|
-
<details class="method-source-toggle">
|
341
|
-
<summary>Source</summary>
|
342
|
-
</details>
|
343
|
-
</div>
|
344
|
-
|
345
|
-
<div class="method-description">
|
346
|
-
<div class="method-source-code" id="read-source">
|
347
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 16</span>
|
348
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read</span>
|
349
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">data_storage_strategy</span>.<span class="ruby-identifier">read</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">file_path</span>)
|
350
|
-
<span class="ruby-keyword">end</span></pre>
|
351
|
-
</div>
|
352
|
-
<p>read from data storage</p>
|
353
|
-
</div>
|
354
|
-
|
355
|
-
|
356
|
-
</div>
|
357
|
-
|
358
|
-
<div id="method-i-replace_student" class="method-detail anchor-link ">
|
359
|
-
<div class="method-header">
|
360
|
-
<div class="method-heading">
|
361
|
-
<a href="#method-i-replace_student" title="Link to this method">
|
362
|
-
<span class="method-name">replace_student</span>
|
363
|
-
<span class="method-args">(id, new_student)</span>
|
364
|
-
</a>
|
365
|
-
</div>
|
366
|
-
</div>
|
367
|
-
|
368
|
-
<div class="method-controls">
|
369
|
-
<details class="method-source-toggle">
|
370
|
-
<summary>Source</summary>
|
371
|
-
</details>
|
372
|
-
</div>
|
373
|
-
|
374
|
-
<div class="method-description">
|
375
|
-
<div class="method-source-code" id="replace_student-source">
|
376
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 62</span>
|
377
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">replace_student</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">new_student</span>)
|
378
|
-
<span class="ruby-identifier">index</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>.<span class="ruby-identifier">find_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">student</span><span class="ruby-operator">|</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span> }
|
379
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">IndexError</span>, <span class="ruby-string">'Unknown student id'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">index</span>.<span class="ruby-identifier">nil?</span>
|
380
|
-
<span class="ruby-keyword">begin</span>
|
381
|
-
<span class="ruby-identifier">check_unique_fileds</span>(<span class="ruby-value">email:</span> <span class="ruby-identifier">new_student</span>.<span class="ruby-identifier">email</span>, <span class="ruby-value">telegram:</span> <span class="ruby-identifier">new_student</span>.<span class="ruby-identifier">telegram</span>,
|
382
|
-
<span class="ruby-value">phone_number:</span> <span class="ruby-identifier">new_student</span>.<span class="ruby-identifier">phone_number</span>, <span class="ruby-value">git:</span> <span class="ruby-identifier">new_student</span>.<span class="ruby-identifier">git</span>, <span class="ruby-value">current_student:</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>[<span class="ruby-identifier">index</span>])
|
383
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
384
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
385
|
-
<span class="ruby-keyword">end</span>
|
386
|
-
<span class="ruby-identifier">new_student</span>.<span class="ruby-identifier">id</span> = <span class="ruby-identifier">id</span>
|
387
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">new_student</span>
|
388
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">write</span>
|
389
|
-
<span class="ruby-keyword">end</span></pre>
|
390
|
-
</div>
|
391
|
-
<p>replace student by id</p>
|
392
|
-
</div>
|
393
|
-
|
394
|
-
|
395
|
-
</div>
|
396
|
-
|
397
|
-
<div id="method-i-sort_by_full_name-21" class="method-detail anchor-link ">
|
398
|
-
<div class="method-header">
|
399
|
-
<div class="method-heading">
|
400
|
-
<a href="#method-i-sort_by_full_name-21" title="Link to this method">
|
401
|
-
<span class="method-name">sort_by_full_name!</span>
|
402
|
-
<span class="method-args">()</span>
|
403
|
-
</a>
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
|
407
|
-
<div class="method-controls">
|
408
|
-
<details class="method-source-toggle">
|
409
|
-
<summary>Source</summary>
|
410
|
-
</details>
|
411
|
-
</div>
|
412
|
-
|
413
|
-
<div class="method-description">
|
414
|
-
<div class="method-source-code" id="sort_by_full_name-21-source">
|
415
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 43</span>
|
416
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sort_by_full_name!</span>
|
417
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>.<span class="ruby-identifier">sort_by!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">student</span><span class="ruby-operator">|</span> <span class="ruby-identifier">student</span>.<span class="ruby-identifier">get_full_name</span> }
|
418
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">write</span>
|
419
|
-
<span class="ruby-keyword">end</span></pre>
|
420
|
-
</div>
|
421
|
-
<p>sort by full name</p>
|
422
|
-
</div>
|
423
|
-
|
424
|
-
|
425
|
-
</div>
|
426
|
-
|
427
|
-
<div id="method-i-write" class="method-detail anchor-link ">
|
428
|
-
<div class="method-header">
|
429
|
-
<div class="method-heading">
|
430
|
-
<a href="#method-i-write" title="Link to this method">
|
431
|
-
<span class="method-name">write</span>
|
432
|
-
<span class="method-args">()</span>
|
433
|
-
</a>
|
434
|
-
</div>
|
435
|
-
</div>
|
436
|
-
|
437
|
-
<div class="method-controls">
|
438
|
-
<details class="method-source-toggle">
|
439
|
-
<summary>Source</summary>
|
440
|
-
</details>
|
441
|
-
</div>
|
442
|
-
|
443
|
-
<div class="method-description">
|
444
|
-
<div class="method-source-code" id="write-source">
|
445
|
-
<pre><span class="ruby-comment"># File lib/models/students_list/students_list_file.rb, line 21</span>
|
446
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>
|
447
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">data_storage_strategy</span>.<span class="ruby-identifier">write</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">file_path</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">students</span>)
|
448
|
-
<span class="ruby-keyword">end</span></pre>
|
449
|
-
</div>
|
450
|
-
<p>write to data storage</p>
|
451
|
-
</div>
|
452
|
-
|
453
|
-
|
454
|
-
</div>
|
455
|
-
|
456
|
-
</section>
|
457
|
-
|
458
|
-
</section>
|
459
|
-
</main>
|
460
|
-
|