maxcube-client 0.5.0 → 0.5.1

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/data/save/20180214-2023/recv.data +12 -0
  4. data/data/save/20180214-2023/recv.yaml +152 -0
  5. data/data/save/20180214-2023/sent.data +10 -0
  6. data/data/save/20180214-2023/sent.yaml +26 -0
  7. data/data/save/20180214-2230/recv.data +2 -0
  8. data/data/save/20180214-2230/recv.yaml +68 -0
  9. data/data/save/20180214-2230/sent.data +1 -0
  10. data/data/save/20180214-2230/sent.yaml +19 -0
  11. data/data/save/20180215-0057/recv.data +3 -0
  12. data/data/save/20180215-0057/recv.yaml +69 -0
  13. data/data/save/20180215-0057/sent.data +2 -0
  14. data/data/save/20180215-0057/sent.yaml +22 -0
  15. data/data/save/20180216-1641/recv.data +4 -0
  16. data/data/save/20180216-1641/recv.yaml +133 -0
  17. data/data/save/20180216-1641/sent.data +2 -0
  18. data/data/save/20180216-1641/sent.yaml +3 -0
  19. data/lib/maxcube/version.rb +1 -1
  20. data/maxcube-client.gemspec +5 -6
  21. data/spec/msg_spec.rb +2117 -0
  22. data/spec/spec_helper.rb +7 -0
  23. metadata +21 -75
  24. data/.gitignore +0 -6
  25. data/.rubocop.yml +0 -29
  26. data/.yardopts +0 -1
  27. data/Gemfile +0 -5
  28. data/bin/console +0 -8
  29. data/bin/maxcube-client +0 -6
  30. data/bin/sample_server +0 -13
  31. data/bin/sample_socket +0 -13
  32. data/bin/setup +0 -6
  33. data/doc/MaxCube.html +0 -502
  34. data/doc/MaxCube/Messages.html +0 -1927
  35. data/doc/MaxCube/Messages/Handler.html +0 -2912
  36. data/doc/MaxCube/Messages/InvalidMessage.html +0 -140
  37. data/doc/MaxCube/Messages/InvalidMessageBody.html +0 -264
  38. data/doc/MaxCube/Messages/InvalidMessageFormat.html +0 -247
  39. data/doc/MaxCube/Messages/InvalidMessageLength.html +0 -247
  40. data/doc/MaxCube/Messages/InvalidMessageType.html +0 -263
  41. data/doc/MaxCube/Messages/Parser.html +0 -520
  42. data/doc/MaxCube/Messages/Serializer.html +0 -701
  43. data/doc/MaxCube/Messages/TCP.html +0 -172
  44. data/doc/MaxCube/Messages/TCP/Handler.html +0 -1396
  45. data/doc/MaxCube/Messages/TCP/Parser.html +0 -462
  46. data/doc/MaxCube/Messages/TCP/Parser/MessageA.html +0 -186
  47. data/doc/MaxCube/Messages/TCP/Parser/MessageC.html +0 -1077
  48. data/doc/MaxCube/Messages/TCP/Parser/MessageF.html +0 -206
  49. data/doc/MaxCube/Messages/TCP/Parser/MessageH.html +0 -338
  50. data/doc/MaxCube/Messages/TCP/Parser/MessageL.html +0 -535
  51. data/doc/MaxCube/Messages/TCP/Parser/MessageM.html +0 -510
  52. data/doc/MaxCube/Messages/TCP/Parser/MessageN.html +0 -226
  53. data/doc/MaxCube/Messages/TCP/Parser/MessageS.html +0 -225
  54. data/doc/MaxCube/Messages/TCP/Serializer.html +0 -460
  55. data/doc/MaxCube/Messages/TCP/Serializer/MessageA.html +0 -186
  56. data/doc/MaxCube/Messages/TCP/Serializer/MessageC.html +0 -185
  57. data/doc/MaxCube/Messages/TCP/Serializer/MessageF.html +0 -206
  58. data/doc/MaxCube/Messages/TCP/Serializer/MessageL.html +0 -185
  59. data/doc/MaxCube/Messages/TCP/Serializer/MessageM.html +0 -428
  60. data/doc/MaxCube/Messages/TCP/Serializer/MessageN.html +0 -209
  61. data/doc/MaxCube/Messages/TCP/Serializer/MessageQ.html +0 -185
  62. data/doc/MaxCube/Messages/TCP/Serializer/MessageS.html +0 -1168
  63. data/doc/MaxCube/Messages/TCP/Serializer/MessageT.html +0 -240
  64. data/doc/MaxCube/Messages/TCP/Serializer/MessageU.html +0 -206
  65. data/doc/MaxCube/Messages/TCP/Serializer/MessageZ.html +0 -252
  66. data/doc/MaxCube/Messages/UDP.html +0 -164
  67. data/doc/MaxCube/Messages/UDP/Handler.html +0 -832
  68. data/doc/MaxCube/Messages/UDP/Parser.html +0 -609
  69. data/doc/MaxCube/Messages/UDP/Parser/MessageH.html +0 -218
  70. data/doc/MaxCube/Messages/UDP/Parser/MessageI.html +0 -215
  71. data/doc/MaxCube/Messages/UDP/Parser/MessageN.html +0 -226
  72. data/doc/MaxCube/Messages/UDP/Serializer.html +0 -484
  73. data/doc/MaxCube/Network.html +0 -167
  74. data/doc/MaxCube/Network/TCP.html +0 -150
  75. data/doc/MaxCube/Network/TCP/Client.html +0 -1930
  76. data/doc/MaxCube/Network/TCP/Client/Commands.html +0 -2457
  77. data/doc/MaxCube/Network/TCP/SampleServer.html +0 -910
  78. data/doc/MaxCube/Network/UDP.html +0 -150
  79. data/doc/MaxCube/Network/UDP/Client.html +0 -518
  80. data/doc/MaxCube/Network/UDP/SampleSocket.html +0 -628
  81. data/doc/MaxCube/Runner.html +0 -355
  82. data/doc/_index.html +0 -518
  83. data/doc/class_list.html +0 -51
  84. data/doc/css/common.css +0 -1
  85. data/doc/css/full_list.css +0 -58
  86. data/doc/css/style.css +0 -499
  87. data/doc/file.README.html +0 -140
  88. data/doc/file_list.html +0 -56
  89. data/doc/frames.html +0 -17
  90. data/doc/index.html +0 -140
  91. data/doc/js/app.js +0 -248
  92. data/doc/js/full_list.js +0 -216
  93. data/doc/js/jquery.js +0 -4
  94. data/doc/method_list.html +0 -1699
  95. data/doc/top-level-namespace.html +0 -110
@@ -1,167 +0,0 @@
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: MaxCube::Network
8
-
9
- &mdash; Documentation by YARD 0.9.12
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 = "MaxCube::Network";
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 (N)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../MaxCube.html" title="MaxCube (module)">MaxCube</a></span></span>
41
- &raquo;
42
- <span class="title">Network</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: MaxCube::Network
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/maxcube/network.rb<span class="defines">,<br />
82
- lib/maxcube/network/tcp.rb,<br /> lib/maxcube/network/udp.rb,<br /> lib/maxcube/network/tcp/client.rb,<br /> lib/maxcube/network/udp/client.rb,<br /> lib/maxcube/network/tcp/sample_server.rb,<br /> lib/maxcube/network/udp/sample_socket.rb,<br /> lib/maxcube/network/tcp/client/commands.rb</span>
83
- </dd>
84
- </dl>
85
-
86
- </div>
87
-
88
- <h2>Overview</h2><div class="docstring">
89
- <div class="discussion">
90
-
91
- <p>Encapsulates network structures providing clients and servers that comply
92
- Cube messages protocol. It utilizes parsing and serializing features from
93
- <span class='object_link'><a href="Messages.html" title="MaxCube::Messages (module)">Messages</a></span>.</p>
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
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Network/TCP.html" title="MaxCube::Network::TCP (module)">TCP</a></span>, <span class='object_link'><a href="Network/UDP.html" title="MaxCube::Network::UDP (module)">UDP</a></span>
106
-
107
-
108
-
109
-
110
- </p>
111
-
112
- <h2>Constant Summary</h2>
113
- <dl class="constants">
114
-
115
- <dt id="LOCALHOST-constant" class="">LOCALHOST =
116
- <div class="docstring">
117
- <div class="discussion">
118
-
119
- <p>Common localhost IP address.</p>
120
-
121
-
122
- </div>
123
- </div>
124
- <div class="tags">
125
-
126
-
127
- </div>
128
- </dt>
129
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>localhost</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
130
-
131
- <dt id="BROADCAST-constant" class="">BROADCAST =
132
- <div class="docstring">
133
- <div class="discussion">
134
-
135
- <p>Common broadcast IP address.</p>
136
-
137
-
138
- </div>
139
- </div>
140
- <div class="tags">
141
-
142
-
143
- </div>
144
- </dt>
145
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&lt;broadcast&gt;</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
146
-
147
- </dl>
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
- </div>
158
-
159
- <div id="footer">
160
- Generated on Fri Feb 16 13:44:01 2018 by
161
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
162
- 0.9.12 (ruby-2.5.0).
163
- </div>
164
-
165
- </div>
166
- </body>
167
- </html>
@@ -1,150 +0,0 @@
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: MaxCube::Network::TCP
8
-
9
- &mdash; Documentation by YARD 0.9.12
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 = "MaxCube::Network::TCP";
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 (T)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../MaxCube.html" title="MaxCube (module)">MaxCube</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Network.html" title="MaxCube::Network (module)">Network</a></span></span>
41
- &raquo;
42
- <span class="title">TCP</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: MaxCube::Network::TCP
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/maxcube/network/tcp.rb<span class="defines">,<br />
82
- lib/maxcube/network/tcp/client.rb,<br /> lib/maxcube/network/tcp/sample_server.rb,<br /> lib/maxcube/network/tcp/client/commands.rb</span>
83
- </dd>
84
- </dl>
85
-
86
- </div>
87
-
88
- <h2>Overview</h2><div class="docstring">
89
- <div class="discussion">
90
-
91
- <p>This module contains classes aimed onto TCP network tools related to Cube
92
- protocol.</p>
93
-
94
-
95
- </div>
96
- </div>
97
- <div class="tags">
98
-
99
-
100
- </div><h2>Defined Under Namespace</h2>
101
- <p class="children">
102
-
103
-
104
-
105
-
106
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="TCP/Client.html" title="MaxCube::Network::TCP::Client (class)">Client</a></span>, <span class='object_link'><a href="TCP/SampleServer.html" title="MaxCube::Network::TCP::SampleServer (class)">SampleServer</a></span>
107
-
108
-
109
- </p>
110
-
111
- <h2>Constant Summary</h2>
112
- <dl class="constants">
113
-
114
- <dt id="PORT-constant" class="">PORT =
115
- <div class="docstring">
116
- <div class="discussion">
117
-
118
- <p>Common port used in Cube TCP communication.</p>
119
-
120
-
121
- </div>
122
- </div>
123
- <div class="tags">
124
-
125
-
126
- </div>
127
- </dt>
128
- <dd><pre class="code"><span class='int'>62_910</span></pre></dd>
129
-
130
- </dl>
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
- </div>
141
-
142
- <div id="footer">
143
- Generated on Fri Feb 16 13:44:01 2018 by
144
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
145
- 0.9.12 (ruby-2.5.0).
146
- </div>
147
-
148
- </div>
149
- </body>
150
- </html>
@@ -1,1930 +0,0 @@
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: MaxCube::Network::TCP::Client
8
-
9
- &mdash; Documentation by YARD 0.9.12
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 = "MaxCube::Network::TCP::Client";
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 (C)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../../MaxCube.html" title="MaxCube (module)">MaxCube</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Network.html" title="MaxCube::Network (module)">Network</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../TCP.html" title="MaxCube::Network::TCP (module)">TCP</a></span></span>
41
- &raquo;
42
- <span class="title">Client</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: MaxCube::Network::TCP::Client
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">MaxCube::Network::TCP::Client</li>
78
-
79
- </ul>
80
- <a href="#" class="inheritanceTree">show all</a>
81
-
82
- </dd>
83
- </dl>
84
-
85
-
86
-
87
-
88
-
89
-
90
- <dl>
91
- <dt>Includes:</dt>
92
- <dd><span class='object_link'><a href="Client/Commands.html" title="MaxCube::Network::TCP::Client::Commands (module)">Commands</a></span></dd>
93
- </dl>
94
-
95
-
96
-
97
-
98
-
99
-
100
- <dl>
101
- <dt>Defined in:</dt>
102
- <dd>lib/maxcube/network/tcp/client.rb<span class="defines">,<br />
103
- lib/maxcube/network/tcp/client/commands.rb</span>
104
- </dd>
105
- </dl>
106
-
107
- </div>
108
-
109
- <h2>Overview</h2><div class="docstring">
110
- <div class="discussion">
111
-
112
- <p>Fundamental class that provides TCP communication with Cube gateway and
113
- connected devices. After connecting to Cube (<span class='object_link'><a href="#connect-instance_method" title="MaxCube::Network::TCP::Client#connect (method)">#connect</a></span>), interactive shell
114
- is launched.</p>
115
-
116
- <p>Communication with Cube is performed via messages, whereas client works
117
- with hashes, which have particular message contents divided and is human
118
- readable. An issue is how to pass contents of hashes as arguments of
119
- message serialization. For simple hashes client provides and option to pass
120
- arguments explicitly on command line. This would be difficult to accomplish
121
- for large hashes with subhashes, so YAML files are used in these cases,
122
- which are able to be generated both automatically and manually. This file
123
- has to be loaded into internal hash before each such message.</p>
124
-
125
- <p>Client interactive shell contains quite detailed usage message.</p>
126
-
127
-
128
- </div>
129
- </div>
130
- <div class="tags">
131
-
132
-
133
- </div><h2>Defined Under Namespace</h2>
134
- <p class="children">
135
-
136
-
137
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Client/Commands.html" title="MaxCube::Network::TCP::Client::Commands (module)">Commands</a></span>
138
-
139
-
140
-
141
-
142
- </p>
143
-
144
- <h2>Constant Summary</h2>
145
- <dl class="constants">
146
-
147
- <dt id="DEFAULT_VERBOSE-constant" class="">DEFAULT_VERBOSE =
148
- <div class="docstring">
149
- <div class="discussion">
150
-
151
- <p>Default verbose mode on startup.</p>
152
-
153
-
154
- </div>
155
- </div>
156
- <div class="tags">
157
-
158
-
159
- </div>
160
- </dt>
161
- <dd><pre class="code"><span class='kw'>true</span></pre></dd>
162
-
163
- <dt id="DEFAULT_PERSIST-constant" class="">DEFAULT_PERSIST =
164
- <div class="docstring">
165
- <div class="discussion">
166
-
167
- <p>Default persist mode on startup.</p>
168
-
169
-
170
- </div>
171
- </div>
172
- <div class="tags">
173
-
174
-
175
- </div>
176
- </dt>
177
- <dd><pre class="code"><span class='kw'>true</span></pre></dd>
178
-
179
- <dt id="ARGS_FROM_HASH-constant" class="">ARGS_FROM_HASH =
180
- <div class="docstring">
181
- <div class="discussion">
182
-
183
- <p>Command line token that enables loading arguments (hash) from file.</p>
184
-
185
-
186
- </div>
187
- </div>
188
- <div class="tags">
189
-
190
-
191
- </div>
192
- </dt>
193
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
194
-
195
- </dl>
196
-
197
-
198
-
199
-
200
-
201
- <h3 class="inherited">Constants included
202
- from <span class='object_link'><a href="Client/Commands.html" title="MaxCube::Network::TCP::Client::Commands (module)">Commands</a></span></h3>
203
- <p class="inherited"><span class='object_link'><a href="Client/Commands.html#COMMANDS-constant" title="MaxCube::Network::TCP::Client::Commands::COMMANDS (constant)">Commands::COMMANDS</a></span></p>
204
-
205
-
206
-
207
-
208
-
209
-
210
- <h2>
211
- Instance Method Summary
212
- <small><a href="#" class="summary_toggle">collapse</a></small>
213
- </h2>
214
-
215
- <ul class="summary">
216
-
217
- <li class="private ">
218
- <span class="summary_signature">
219
-
220
- <a href="#args_from_hash%3F-instance_method" title="#args_from_hash? (instance method)">#<strong>args_from_hash?</strong>(args) &#x21d2; Boolean </a>
221
-
222
-
223
-
224
- </span>
225
-
226
-
227
-
228
- <span class="note title private">private</span>
229
-
230
-
231
-
232
-
233
-
234
- <span class="summary_desc"><div class='inline'>
235
- <p>Whether to enable loading arguments (hash) from file.</p>
236
- </div></span>
237
-
238
- </li>
239
-
240
-
241
- <li class="private ">
242
- <span class="summary_signature">
243
-
244
- <a href="#buffer-instance_method" title="#buffer (instance method)">#<strong>buffer</strong>(dir_key, data_key, history = false) &#x21d2; Array&lt;Hash&gt;, String </a>
245
-
246
-
247
-
248
- </span>
249
-
250
-
251
-
252
- <span class="note title private">private</span>
253
-
254
-
255
-
256
-
257
-
258
- <span class="summary_desc"><div class='inline'>
259
- <p>Returns only current or all (without or with history) collected part of
260
- buffer and history (contents of buffer is moved to history on clear
261
- command).</p>
262
- </div></span>
263
-
264
- </li>
265
-
266
-
267
- <li class="public ">
268
- <span class="summary_signature">
269
-
270
- <a href="#close-instance_method" title="#close (instance method)">#<strong>close</strong> &#x21d2; Object </a>
271
-
272
-
273
-
274
- </span>
275
-
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
- <span class="summary_desc"><div class='inline'>
285
- <p>Closes client gracefully.</p>
286
- </div></span>
287
-
288
- </li>
289
-
290
-
291
- <li class="private ">
292
- <span class="summary_signature">
293
-
294
- <a href="#command-instance_method" title="#command (instance method)">#<strong>command</strong>(line) &#x21d2; Object </a>
295
-
296
-
297
-
298
- </span>
299
-
300
-
301
-
302
- <span class="note title private">private</span>
303
-
304
-
305
-
306
-
307
-
308
- <span class="summary_desc"><div class='inline'>
309
- <p>Executes command from shell command line.</p>
310
- </div></span>
311
-
312
- </li>
313
-
314
-
315
- <li class="public ">
316
- <span class="summary_signature">
317
-
318
- <a href="#connect-instance_method" title="#connect (instance method)">#<strong>connect</strong>(host = LOCALHOST, port = PORT) &#x21d2; Object </a>
319
-
320
-
321
-
322
- </span>
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
- <span class="summary_desc"><div class='inline'>
333
- <p>Connects to concrete address and starts interactive shell (<span class='object_link'><a href="#shell-instance_method" title="MaxCube::Network::TCP::Client#shell (method)">#shell</a></span>).</p>
334
- </div></span>
335
-
336
- </li>
337
-
338
-
339
- <li class="public ">
340
- <span class="summary_signature">
341
-
342
- <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(verbose: DEFAULT_VERBOSE, persist: DEFAULT_PERSIST) &#x21d2; Client </a>
343
-
344
-
345
-
346
- </span>
347
-
348
-
349
- <span class="note title constructor">constructor</span>
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
- <span class="summary_desc"><div class='inline'>
359
- <p>Creates all necessary internal variables.</p>
360
- </div></span>
361
-
362
- </li>
363
-
364
-
365
- <li class="private ">
366
- <span class="summary_signature">
367
-
368
- <a href="#print_hash-instance_method" title="#print_hash (instance method)">#<strong>print_hash</strong>(hash) &#x21d2; Object </a>
369
-
370
-
371
-
372
- </span>
373
-
374
-
375
-
376
- <span class="note title private">private</span>
377
-
378
-
379
-
380
-
381
-
382
- <span class="summary_desc"><div class='inline'>
383
- <p>Prints hash in human readable way.</p>
384
- </div></span>
385
-
386
- </li>
387
-
388
-
389
- <li class="public ">
390
- <span class="summary_signature">
391
-
392
- <a href="#receiver-instance_method" title="#receiver (instance method)">#<strong>receiver</strong> &#x21d2; Object </a>
393
-
394
-
395
-
396
- </span>
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
- <span class="summary_desc"><div class='inline'>
407
- <p>Routine started in separate thread that receives and parses all incoming
408
- messages in loop and stores them info thread-safe queue.</p>
409
- </div></span>
410
-
411
- </li>
412
-
413
-
414
- <li class="private ">
415
- <span class="summary_signature">
416
-
417
- <a href="#refresh_buffer-instance_method" title="#refresh_buffer (instance method)">#<strong>refresh_buffer</strong> &#x21d2; Object </a>
418
-
419
-
420
-
421
- </span>
422
-
423
-
424
-
425
- <span class="note title private">private</span>
426
-
427
-
428
-
429
-
430
-
431
- <span class="summary_desc"><div class='inline'>
432
- <p>Moves contents of receiver&#39;s queue to internal buffer.</p>
433
- </div></span>
434
-
435
- </li>
436
-
437
-
438
- <li class="private ">
439
- <span class="summary_signature">
440
-
441
- <a href="#send_msg-instance_method" title="#send_msg (instance method)">#<strong>send_msg</strong>(type, *args, **opts) &#x21d2; Object </a>
442
-
443
-
444
-
445
- </span>
446
-
447
-
448
-
449
- <span class="note title private">private</span>
450
-
451
-
452
-
453
-
454
-
455
- <span class="summary_desc"><div class='inline'>
456
- <p>Performs message serialization and sends it to Cube.</p>
457
- </div></span>
458
-
459
- </li>
460
-
461
-
462
- <li class="private ">
463
- <span class="summary_signature">
464
-
465
- <a href="#send_msg_hash-instance_method" title="#send_msg_hash (instance method)">#<strong>send_msg_hash</strong>(type, *args, **opts) &#x21d2; Hash </a>
466
-
467
-
468
-
469
- </span>
470
-
471
-
472
-
473
- <span class="note title private">private</span>
474
-
475
-
476
-
477
-
478
-
479
- <span class="summary_desc"><div class='inline'>
480
- <p>Returns hash with contents necessary for serialization of message of given
481
- message type.</p>
482
- </div></span>
483
-
484
- </li>
485
-
486
-
487
- <li class="private ">
488
- <span class="summary_signature">
489
-
490
- <a href="#send_msg_hash_from_internal-instance_method" title="#send_msg_hash_from_internal (instance method)">#<strong>send_msg_hash_from_internal</strong>(*args, **_opts) &#x21d2; Hash<sup>?</sup> </a>
491
-
492
-
493
-
494
- </span>
495
-
496
-
497
-
498
- <span class="note title private">private</span>
499
-
500
-
501
-
502
-
503
-
504
- <span class="summary_desc"><div class='inline'>
505
- <p>Returns hash via <span class='object_link'><a href="Client/Commands.html#cmd_load-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_load (method)">Commands#cmd_load</a></span>.</p>
506
- </div></span>
507
-
508
- </li>
509
-
510
-
511
- <li class="private ">
512
- <span class="summary_signature">
513
-
514
- <a href="#send_msg_hash_from_keys_args-instance_method" title="#send_msg_hash_from_keys_args (instance method)">#<strong>send_msg_hash_from_keys_args</strong>(type, *args, **opts) &#x21d2; Hash<sup>?</sup> </a>
515
-
516
-
517
-
518
- </span>
519
-
520
-
521
-
522
- <span class="note title private">private</span>
523
-
524
-
525
-
526
-
527
-
528
- <span class="summary_desc"><div class='inline'>
529
- <p>Zips <code>args</code> with appropriate keys according to
530
- <span class='object_link'><a href="../../Messages/Handler.html#msg_type_hash_keys-instance_method" title="MaxCube::Messages::Handler#msg_type_hash_keys (method)">Messages::Handler#msg_type_hash_keys</a></span> and
531
- <span class='object_link'><a href="../../Messages/Handler.html#msg_type_hash_opt_keys-instance_method" title="MaxCube::Messages::Handler#msg_type_hash_opt_keys (method)">Messages::Handler#msg_type_hash_opt_keys</a></span>.</p>
532
- </div></span>
533
-
534
- </li>
535
-
536
-
537
- <li class="public ">
538
- <span class="summary_signature">
539
-
540
- <a href="#shell-instance_method" title="#shell (instance method)">#<strong>shell</strong> &#x21d2; Object </a>
541
-
542
-
543
-
544
- </span>
545
-
546
-
547
-
548
-
549
-
550
-
551
-
552
-
553
-
554
- <span class="summary_desc"><div class='inline'>
555
- <p>Interactive shell that maintains all operations with Cube.</p>
556
- </div></span>
557
-
558
- </li>
559
-
560
-
561
- </ul>
562
-
563
-
564
-
565
-
566
-
567
-
568
-
569
-
570
-
571
-
572
-
573
- <h3 class="inherited">Methods included from <span class='object_link'><a href="Client/Commands.html" title="MaxCube::Network::TCP::Client::Commands (module)">Commands</a></span></h3>
574
- <p class="inherited"><span class='object_link'><a href="Client/Commands.html#assign_hash-instance_method" title="MaxCube::Network::TCP::Client::Commands#assign_hash (method)">#assign_hash</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_clear-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_clear (method)">#cmd_clear</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_config-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_config (method)">#cmd_config</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_data-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_data (method)">#cmd_data</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_delete-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_delete (method)">#cmd_delete</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_dump-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_dump (method)">#cmd_dump</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_history-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_history (method)">#cmd_history</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_list-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_list (method)">#cmd_list</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_load-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_load (method)">#cmd_load</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_metadata-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_metadata (method)">#cmd_metadata</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_ntp-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_ntp (method)">#cmd_ntp</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_pair-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_pair (method)">#cmd_pair</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_persist-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_persist (method)">#cmd_persist</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_quit-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_quit (method)">#cmd_quit</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_reset-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_reset (method)">#cmd_reset</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_save-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_save (method)">#cmd_save</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_send-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_send (method)">#cmd_send</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_url-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_url (method)">#cmd_url</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_usage-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_usage (method)">#cmd_usage</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_verbose-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_verbose (method)">#cmd_verbose</a></span>, <span class='object_link'><a href="Client/Commands.html#cmd_wake-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_wake (method)">#cmd_wake</a></span>, <span class='object_link'><a href="Client/Commands.html#list_hashes-instance_method" title="MaxCube::Network::TCP::Client::Commands#list_hashes (method)">#list_hashes</a></span>, <span class='object_link'><a href="Client/Commands.html#load_hash-instance_method" title="MaxCube::Network::TCP::Client::Commands#load_hash (method)">#load_hash</a></span>, <span class='object_link'><a href="Client/Commands.html#parse_hash-instance_method" title="MaxCube::Network::TCP::Client::Commands#parse_hash (method)">#parse_hash</a></span>, <span class='object_link'><a href="Client/Commands.html#toggle-instance_method" title="MaxCube::Network::TCP::Client::Commands#toggle (method)">#toggle</a></span>, <span class='object_link'><a href="Client/Commands.html#usage_cmd-instance_method" title="MaxCube::Network::TCP::Client::Commands#usage_cmd (method)">#usage_cmd</a></span></p>
575
- <div id="constructor_details" class="method_details_list">
576
- <h2>Constructor Details</h2>
577
-
578
- <div class="method_details first">
579
- <h3 class="signature first" id="initialize-instance_method">
580
-
581
- #<strong>initialize</strong>(verbose: DEFAULT_VERBOSE, persist: DEFAULT_PERSIST) &#x21d2; <tt><span class='object_link'><a href="" title="MaxCube::Network::TCP::Client (class)">Client</a></span></tt>
582
-
583
-
584
-
585
-
586
-
587
- </h3><div class="docstring">
588
- <div class="discussion">
589
-
590
- <p>Creates all necessary internal variables. Internal hash is invalid on
591
- startup.</p>
592
-
593
-
594
- </div>
595
- </div>
596
- <div class="tags">
597
- <p class="tag_title">Parameters:</p>
598
- <ul class="param">
599
-
600
- <li>
601
-
602
- <span class='name'>verbose</span>
603
-
604
-
605
- <span class='type'>(<tt>Boolean</tt>)</span>
606
-
607
-
608
-
609
- &mdash;
610
- <div class='inline'>
611
- <p>verbose mode on startup.</p>
612
- </div>
613
-
614
- </li>
615
-
616
- <li>
617
-
618
- <span class='name'>persist</span>
619
-
620
-
621
- <span class='type'>(<tt>Boolean</tt>)</span>
622
-
623
-
624
-
625
- &mdash;
626
- <div class='inline'>
627
- <p>persist mode on startup.</p>
628
- </div>
629
-
630
- </li>
631
-
632
- </ul>
633
-
634
-
635
- </div><table class="source_code">
636
- <tr>
637
- <td>
638
- <pre class="lines">
639
-
640
-
641
- 37
642
- 38
643
- 39
644
- 40
645
- 41
646
- 42
647
- 43
648
- 44
649
- 45
650
- 46
651
- 47
652
- 48
653
- 49
654
- 50
655
- 51
656
- 52
657
- 53
658
- 54
659
- 55
660
- 56</pre>
661
- </td>
662
- <td>
663
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 37</span>
664
-
665
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>verbose:</span> <span class='const'><span class='object_link'><a href="#DEFAULT_VERBOSE-constant" title="MaxCube::Network::TCP::Client::DEFAULT_VERBOSE (constant)">DEFAULT_VERBOSE</a></span></span><span class='comma'>,</span> <span class='label'>persist:</span> <span class='const'><span class='object_link'><a href="#DEFAULT_PERSIST-constant" title="MaxCube::Network::TCP::Client::DEFAULT_PERSIST (constant)">DEFAULT_PERSIST</a></span></span><span class='rparen'>)</span>
666
- <span class='ivar'>@parser</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Messages.html" title="MaxCube::Messages (module)">Messages</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Messages/TCP.html" title="MaxCube::Messages::TCP (module)">TCP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Messages/TCP/Parser.html" title="MaxCube::Messages::TCP::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
667
- <span class='ivar'>@serializer</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Messages.html" title="MaxCube::Messages (module)">Messages</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Messages/TCP.html" title="MaxCube::Messages::TCP (module)">TCP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Messages/TCP/Serializer.html" title="MaxCube::Messages::TCP::Serializer (class)">Serializer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
668
- <span class='ivar'>@queue</span> <span class='op'>=</span> <span class='const'>Queue</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
669
-
670
- <span class='ivar'>@buffer</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>recv:</span> <span class='lbrace'>{</span> <span class='label'>hashes:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>data:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='comma'>,</span>
671
- <span class='label'>sent:</span> <span class='lbrace'>{</span> <span class='label'>hashes:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>data:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
672
- <span class='ivar'>@history</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>recv:</span> <span class='lbrace'>{</span> <span class='label'>hashes:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>data:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='comma'>,</span>
673
- <span class='label'>sent:</span> <span class='lbrace'>{</span> <span class='label'>hashes:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>data:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
674
-
675
- <span class='ivar'>@hash</span> <span class='op'>=</span> <span class='kw'>nil</span>
676
- <span class='ivar'>@hash_set</span> <span class='op'>=</span> <span class='kw'>false</span>
677
-
678
- <span class='ivar'>@data_dir</span> <span class='op'>=</span> <span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../../MaxCube.html" title="MaxCube (module)">MaxCube</a></span></span><span class='period'>.</span><span class='id identifier rubyid_data_dir'><span class='object_link'><a href="../../../MaxCube.html#data_dir-class_method" title="MaxCube.data_dir (method)">data_dir</a></span></span><span class='rparen'>)</span>
679
- <span class='ivar'>@load_data_dir</span> <span class='op'>=</span> <span class='ivar'>@data_dir</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>load</span><span class='tstring_end'>&#39;</span></span>
680
- <span class='ivar'>@save_data_dir</span> <span class='op'>=</span> <span class='ivar'>@data_dir</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>save</span><span class='tstring_end'>&#39;</span></span>
681
-
682
- <span class='ivar'>@verbose</span> <span class='op'>=</span> <span class='id identifier rubyid_verbose'>verbose</span>
683
- <span class='ivar'>@persist</span> <span class='op'>=</span> <span class='id identifier rubyid_persist'>persist</span>
684
- <span class='kw'>end</span></pre>
685
- </td>
686
- </tr>
687
- </table>
688
- </div>
689
-
690
- </div>
691
-
692
-
693
- <div id="instance_method_details" class="method_details_list">
694
- <h2>Instance Method Details</h2>
695
-
696
-
697
- <div class="method_details first">
698
- <h3 class="signature first" id="args_from_hash?-instance_method">
699
-
700
- #<strong>args_from_hash?</strong>(args) &#x21d2; <tt>Boolean</tt> <span class="extras">(private)</span>
701
-
702
-
703
-
704
-
705
-
706
- </h3><div class="docstring">
707
- <div class="discussion">
708
-
709
- <p>Returns whether to enable loading arguments (hash) from file.</p>
710
-
711
-
712
- </div>
713
- </div>
714
- <div class="tags">
715
- <p class="tag_title">Parameters:</p>
716
- <ul class="param">
717
-
718
- <li>
719
-
720
- <span class='name'>args</span>
721
-
722
-
723
- <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
724
-
725
-
726
-
727
- &mdash;
728
- <div class='inline'>
729
- <p>arguments from command line.</p>
730
- </div>
731
-
732
- </li>
733
-
734
- </ul>
735
-
736
- <p class="tag_title">Returns:</p>
737
- <ul class="return">
738
-
739
- <li>
740
-
741
-
742
- <span class='type'>(<tt>Boolean</tt>)</span>
743
-
744
-
745
-
746
- &mdash;
747
- <div class='inline'>
748
- <p>whether to enable loading arguments (hash) from file.</p>
749
- </div>
750
-
751
- </li>
752
-
753
- </ul>
754
-
755
- </div><table class="source_code">
756
- <tr>
757
- <td>
758
- <pre class="lines">
759
-
760
-
761
- 218
762
- 219
763
- 220</pre>
764
- </td>
765
- <td>
766
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 218</span>
767
-
768
- <span class='kw'>def</span> <span class='id identifier rubyid_args_from_hash?'>args_from_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
769
- <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="#ARGS_FROM_HASH-constant" title="MaxCube::Network::TCP::Client::ARGS_FROM_HASH (constant)">ARGS_FROM_HASH</a></span></span>
770
- <span class='kw'>end</span></pre>
771
- </td>
772
- </tr>
773
- </table>
774
- </div>
775
-
776
- <div class="method_details ">
777
- <h3 class="signature " id="buffer-instance_method">
778
-
779
- #<strong>buffer</strong>(dir_key, data_key, history = false) &#x21d2; <tt>Array&lt;Hash&gt;</tt>, <tt>String</tt> <span class="extras">(private)</span>
780
-
781
-
782
-
783
-
784
-
785
- </h3><div class="docstring">
786
- <div class="discussion">
787
-
788
- <p>Returns only current or all (without or with history) collected part of
789
- buffer and history (contents of buffer is moved to history on clear
790
- command).</p>
791
-
792
-
793
- </div>
794
- </div>
795
- <div class="tags">
796
- <p class="tag_title">Parameters:</p>
797
- <ul class="param">
798
-
799
- <li>
800
-
801
- <span class='name'>dir_key</span>
802
-
803
-
804
- <span class='type'>(<tt>:recv</tt>, <tt>:sent</tt>)</span>
805
-
806
-
807
-
808
- &mdash;
809
- <div class='inline'>
810
- <p>received or sent data.</p>
811
- </div>
812
-
813
- </li>
814
-
815
- <li>
816
-
817
- <span class='name'>data_key</span>
818
-
819
-
820
- <span class='type'>(<tt>:hashes</tt>, <tt>:data</tt>)</span>
821
-
822
-
823
-
824
- &mdash;
825
- <div class='inline'>
826
- <p>hashes or raw data (set of messages).</p>
827
- </div>
828
-
829
- </li>
830
-
831
- <li>
832
-
833
- <span class='name'>history</span>
834
-
835
-
836
- <span class='type'>(<tt>Boolean</tt>)</span>
837
-
838
-
839
- <em class="default">(defaults to: <tt>false</tt>)</em>
840
-
841
-
842
- &mdash;
843
- <div class='inline'>
844
- <p>whether to include history.</p>
845
- </div>
846
-
847
- </li>
848
-
849
- </ul>
850
-
851
- <p class="tag_title">Returns:</p>
852
- <ul class="return">
853
-
854
- <li>
855
-
856
-
857
- <span class='type'>(<tt>Array&lt;Hash&gt;</tt>, <tt>String</tt>)</span>
858
-
859
-
860
-
861
- &mdash;
862
- <div class='inline'>
863
- <p>demanded data.</p>
864
- </div>
865
-
866
- </li>
867
-
868
- </ul>
869
-
870
- </div><table class="source_code">
871
- <tr>
872
- <td>
873
- <pre class="lines">
874
-
875
-
876
- 146
877
- 147
878
- 148
879
- 149</pre>
880
- </td>
881
- <td>
882
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 146</span>
883
-
884
- <span class='kw'>def</span> <span class='id identifier rubyid_buffer'>buffer</span><span class='lparen'>(</span><span class='id identifier rubyid_dir_key'>dir_key</span><span class='comma'>,</span> <span class='id identifier rubyid_data_key'>data_key</span><span class='comma'>,</span> <span class='id identifier rubyid_history'>history</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
885
- <span class='kw'>return</span> <span class='ivar'>@buffer</span><span class='lbracket'>[</span><span class='id identifier rubyid_dir_key'>dir_key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_data_key'>data_key</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_history'>history</span>
886
- <span class='ivar'>@history</span><span class='lbracket'>[</span><span class='id identifier rubyid_dir_key'>dir_key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_data_key'>data_key</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='ivar'>@buffer</span><span class='lbracket'>[</span><span class='id identifier rubyid_dir_key'>dir_key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_data_key'>data_key</span><span class='rbracket'>]</span>
887
- <span class='kw'>end</span></pre>
888
- </td>
889
- </tr>
890
- </table>
891
- </div>
892
-
893
- <div class="method_details ">
894
- <h3 class="signature " id="close-instance_method">
895
-
896
- #<strong>close</strong> &#x21d2; <tt>Object</tt>
897
-
898
-
899
-
900
-
901
-
902
- </h3><div class="docstring">
903
- <div class="discussion">
904
-
905
- <p>Closes client gracefully.</p>
906
-
907
-
908
- </div>
909
- </div>
910
- <div class="tags">
911
-
912
-
913
- </div><table class="source_code">
914
- <tr>
915
- <td>
916
- <pre class="lines">
917
-
918
-
919
- 119
920
- 120
921
- 121
922
- 122
923
- 123
924
- 124</pre>
925
- </td>
926
- <td>
927
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 119</span>
928
-
929
- <span class='kw'>def</span> <span class='id identifier rubyid_close'>close</span>
930
- <span class='const'>STDIN</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
931
- <span class='id identifier rubyid_send_msg'>send_msg</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>q</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
932
- <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
933
- <span class='ivar'>@thread</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span>
934
- <span class='kw'>end</span></pre>
935
- </td>
936
- </tr>
937
- </table>
938
- </div>
939
-
940
- <div class="method_details ">
941
- <h3 class="signature " id="command-instance_method">
942
-
943
- #<strong>command</strong>(line) &#x21d2; <tt>Object</tt> <span class="extras">(private)</span>
944
-
945
-
946
-
947
-
948
-
949
- </h3><div class="docstring">
950
- <div class="discussion">
951
-
952
- <p>Executes command from shell command line. It calls a method dynamically
953
- according to <span class='object_link'><a href="Client/Commands.html#COMMANDS-constant" title="MaxCube::Network::TCP::Client::Commands::COMMANDS (constant)">MaxCube::Network::TCP::Client::Commands::COMMANDS</a></span>, or displays usage message <span class='object_link'><a href="Client/Commands.html#cmd_usage-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_usage (method)">MaxCube::Network::TCP::Client::Commands#cmd_usage</a></span>.</p>
954
-
955
-
956
- </div>
957
- </div>
958
- <div class="tags">
959
- <p class="tag_title">Parameters:</p>
960
- <ul class="param">
961
-
962
- <li>
963
-
964
- <span class='name'>line</span>
965
-
966
-
967
- <span class='type'>(<tt>String</tt>)</span>
968
-
969
-
970
-
971
- &mdash;
972
- <div class='inline'>
973
- <p>command line from <code>STDIN</code></p>
974
- </div>
975
-
976
- </li>
977
-
978
- </ul>
979
-
980
-
981
- </div><table class="source_code">
982
- <tr>
983
- <td>
984
- <pre class="lines">
985
-
986
-
987
- 155
988
- 156
989
- 157
990
- 158
991
- 159
992
- 160
993
- 161
994
- 162
995
- 163
996
- 164
997
- 165
998
- 166
999
- 167
1000
- 168
1001
- 169</pre>
1002
- </td>
1003
- <td>
1004
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 155</span>
1005
-
1006
- <span class='kw'>def</span> <span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='id identifier rubyid_line'>line</span><span class='rparen'>)</span>
1007
- <span class='id identifier rubyid_cmd'>cmd</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span>
1008
- <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_cmd'>cmd</span>
1009
-
1010
- <span class='kw'>return</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cmd_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd'>cmd</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="Client/Commands.html#COMMANDS-constant" title="MaxCube::Network::TCP::Client::Commands::COMMANDS (constant)">COMMANDS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rparen'>)</span>
1011
-
1012
- <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Client/Commands.html#COMMANDS-constant" title="MaxCube::Network::TCP::Client::Commands::COMMANDS (constant)">COMMANDS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1013
- <span class='kw'>return</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cmd_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_keys'>keys</span>
1014
-
1015
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unrecognized command: &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd'>cmd</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;</span><span class='tstring_end'>&quot;</span></span>
1016
- <span class='id identifier rubyid_cmd_usage'>cmd_usage</span>
1017
- <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
1018
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid arguments: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_args'>args</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
1019
- <span class='id identifier rubyid_cmd_usage'>cmd_usage</span>
1020
- <span class='kw'>end</span></pre>
1021
- </td>
1022
- </tr>
1023
- </table>
1024
- </div>
1025
-
1026
- <div class="method_details ">
1027
- <h3 class="signature " id="connect-instance_method">
1028
-
1029
- #<strong>connect</strong>(host = LOCALHOST, port = PORT) &#x21d2; <tt>Object</tt>
1030
-
1031
-
1032
-
1033
-
1034
-
1035
- </h3><div class="docstring">
1036
- <div class="discussion">
1037
-
1038
- <p>Connects to concrete address and starts interactive shell (<span class='object_link'><a href="#shell-instance_method" title="MaxCube::Network::TCP::Client#shell (method)">#shell</a></span>). Calls
1039
- <span class='object_link'><a href="#receiver-instance_method" title="MaxCube::Network::TCP::Client#receiver (method)">#receiver</a></span> in separate thread to receive all incoming messages.</p>
1040
-
1041
-
1042
- </div>
1043
- </div>
1044
- <div class="tags">
1045
- <p class="tag_title">Parameters:</p>
1046
- <ul class="param">
1047
-
1048
- <li>
1049
-
1050
- <span class='name'>host</span>
1051
-
1052
-
1053
- <span class='type'></span>
1054
-
1055
-
1056
- <em class="default">(defaults to: <tt>LOCALHOST</tt>)</em>
1057
-
1058
-
1059
- &mdash;
1060
- <div class='inline'>
1061
- <p>remote host address.</p>
1062
- </div>
1063
-
1064
- </li>
1065
-
1066
- <li>
1067
-
1068
- <span class='name'>port</span>
1069
-
1070
-
1071
- <span class='type'></span>
1072
-
1073
-
1074
- <em class="default">(defaults to: <tt>PORT</tt>)</em>
1075
-
1076
-
1077
- &mdash;
1078
- <div class='inline'>
1079
- <p>remote host port.</p>
1080
- </div>
1081
-
1082
- </li>
1083
-
1084
- </ul>
1085
-
1086
-
1087
- </div><table class="source_code">
1088
- <tr>
1089
- <td>
1090
- <pre class="lines">
1091
-
1092
-
1093
- 62
1094
- 63
1095
- 64
1096
- 65
1097
- 66</pre>
1098
- </td>
1099
- <td>
1100
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 62</span>
1101
-
1102
- <span class='kw'>def</span> <span class='id identifier rubyid_connect'>connect</span><span class='lparen'>(</span><span class='id identifier rubyid_host'>host</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Network.html#LOCALHOST-constant" title="MaxCube::Network::LOCALHOST (constant)">LOCALHOST</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_port'>port</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../TCP.html#PORT-constant" title="MaxCube::Network::TCP::PORT (constant)">PORT</a></span></span><span class='rparen'>)</span>
1103
- <span class='ivar'>@socket</span> <span class='op'>=</span> <span class='const'>TCPSocket</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_host'>host</span><span class='comma'>,</span> <span class='id identifier rubyid_port'>port</span><span class='rparen'>)</span>
1104
- <span class='ivar'>@thread</span> <span class='op'>=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='symbol'>:receiver</span><span class='rparen'>)</span>
1105
- <span class='id identifier rubyid_shell'>shell</span>
1106
- <span class='kw'>end</span></pre>
1107
- </td>
1108
- </tr>
1109
- </table>
1110
- </div>
1111
-
1112
- <div class="method_details ">
1113
- <h3 class="signature " id="print_hash-instance_method">
1114
-
1115
- #<strong>print_hash</strong>(hash) &#x21d2; <tt>Object</tt> <span class="extras">(private)</span>
1116
-
1117
-
1118
-
1119
-
1120
-
1121
- </h3><div class="docstring">
1122
- <div class="discussion">
1123
-
1124
- <p>Prints hash in human readable way.</p>
1125
-
1126
-
1127
- </div>
1128
- </div>
1129
- <div class="tags">
1130
- <p class="tag_title">Parameters:</p>
1131
- <ul class="param">
1132
-
1133
- <li>
1134
-
1135
- <span class='name'>hash</span>
1136
-
1137
-
1138
- <span class='type'>(<tt>Hash</tt>)</span>
1139
-
1140
-
1141
-
1142
- &mdash;
1143
- <div class='inline'>
1144
- <p>input hash.</p>
1145
- </div>
1146
-
1147
- </li>
1148
-
1149
- </ul>
1150
-
1151
-
1152
- </div><table class="source_code">
1153
- <tr>
1154
- <td>
1155
- <pre class="lines">
1156
-
1157
-
1158
- 282
1159
- 283
1160
- 284</pre>
1161
- </td>
1162
- <td>
1163
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 282</span>
1164
-
1165
- <span class='kw'>def</span> <span class='id identifier rubyid_print_hash'>print_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
1166
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_to_yaml'>to_yaml</span>
1167
- <span class='kw'>end</span></pre>
1168
- </td>
1169
- </tr>
1170
- </table>
1171
- </div>
1172
-
1173
- <div class="method_details ">
1174
- <h3 class="signature " id="receiver-instance_method">
1175
-
1176
- #<strong>receiver</strong> &#x21d2; <tt>Object</tt>
1177
-
1178
-
1179
-
1180
-
1181
-
1182
- </h3><div class="docstring">
1183
- <div class="discussion">
1184
-
1185
- <p>Routine started in separate thread that receives and parses all incoming
1186
- messages in loop and stores them info thread-safe queue. Parsing is done
1187
- via <span class='object_link'><a href="../../Messages/TCP/Parser.html#parse_tcp_msg-instance_method" title="MaxCube::Messages::TCP::Parser#parse_tcp_msg (method)">Messages::TCP::Parser#parse_tcp_msg</a></span>. It should close gracefully on
1188
- any <code>IOError</code> or on shell&#39;s initiative.</p>
1189
-
1190
-
1191
- </div>
1192
- </div>
1193
- <div class="tags">
1194
-
1195
-
1196
- </div><table class="source_code">
1197
- <tr>
1198
- <td>
1199
- <pre class="lines">
1200
-
1201
-
1202
- 75
1203
- 76
1204
- 77
1205
- 78
1206
- 79
1207
- 80
1208
- 81
1209
- 82
1210
- 83
1211
- 84
1212
- 85
1213
- 86
1214
- 87
1215
- 88
1216
- 89
1217
- 90
1218
- 91</pre>
1219
- </td>
1220
- <td>
1221
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 75</span>
1222
-
1223
- <span class='kw'>def</span> <span class='id identifier rubyid_receiver'>receiver</span>
1224
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&lt;Starting receiver thread ...&gt;</span><span class='tstring_end'>&#39;</span></span>
1225
- <span class='kw'>while</span> <span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_gets'>gets</span><span class='rparen'>)</span>
1226
- <span class='id identifier rubyid_hashes'>hashes</span> <span class='op'>=</span> <span class='ivar'>@parser</span><span class='period'>.</span><span class='id identifier rubyid_parse_tcp_data'>parse_tcp_data</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
1227
- <span class='kw'>if</span> <span class='ivar'>@verbose</span>
1228
- <span class='id identifier rubyid_hashes'>hashes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='op'>|</span> <span class='id identifier rubyid_print_hash'>print_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_h'>h</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1229
- <span class='id identifier rubyid_puts'>puts</span>
1230
- <span class='kw'>end</span>
1231
- <span class='ivar'>@queue</span> <span class='op'>&lt;&lt;</span> <span class='lbracket'>[</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_hashes'>hashes</span><span class='rbracket'>]</span>
1232
- <span class='kw'>end</span>
1233
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>IOError</span>
1234
- <span class='kw'>rescue</span> <span class='const'>IOError</span>
1235
- <span class='const'>STDIN</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
1236
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&lt;Closing receiver thread ...&gt;</span><span class='tstring_end'>&#39;</span></span>
1237
- <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="../../Messages.html" title="MaxCube::Messages (module)">Messages</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Messages/InvalidMessage.html" title="MaxCube::Messages::InvalidMessage (class)">InvalidMessage</a></span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1238
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_capitalize'>capitalize</span>
1239
- <span class='kw'>end</span></pre>
1240
- </td>
1241
- </tr>
1242
- </table>
1243
- </div>
1244
-
1245
- <div class="method_details ">
1246
- <h3 class="signature " id="refresh_buffer-instance_method">
1247
-
1248
- #<strong>refresh_buffer</strong> &#x21d2; <tt>Object</tt> <span class="extras">(private)</span>
1249
-
1250
-
1251
-
1252
-
1253
-
1254
- </h3><div class="docstring">
1255
- <div class="discussion">
1256
-
1257
- <p>Moves contents of receiver&#39;s queue to internal buffer. Queue is being
1258
- filled from <span class='object_link'><a href="#receiver-instance_method" title="MaxCube::Network::TCP::Client#receiver (method)">#receiver</a></span>. Operation is thread-safe.</p>
1259
-
1260
-
1261
- </div>
1262
- </div>
1263
- <div class="tags">
1264
-
1265
-
1266
- </div><table class="source_code">
1267
- <tr>
1268
- <td>
1269
- <pre class="lines">
1270
-
1271
-
1272
- 131
1273
- 132
1274
- 133
1275
- 134
1276
- 135
1277
- 136
1278
- 137</pre>
1279
- </td>
1280
- <td>
1281
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 131</span>
1282
-
1283
- <span class='kw'>def</span> <span class='id identifier rubyid_refresh_buffer'>refresh_buffer</span>
1284
- <span class='kw'>until</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1285
- <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_hashes'>hashes</span> <span class='op'>=</span> <span class='ivar'>@queue</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
1286
- <span class='ivar'>@buffer</span><span class='lbracket'>[</span><span class='symbol'>:recv</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_data'>data</span>
1287
- <span class='ivar'>@buffer</span><span class='lbracket'>[</span><span class='symbol'>:recv</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:hashes</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_hashes'>hashes</span>
1288
- <span class='kw'>end</span>
1289
- <span class='kw'>end</span></pre>
1290
- </td>
1291
- </tr>
1292
- </table>
1293
- </div>
1294
-
1295
- <div class="method_details ">
1296
- <h3 class="signature " id="send_msg-instance_method">
1297
-
1298
- #<strong>send_msg</strong>(type, *args, **opts) &#x21d2; <tt>Object</tt> <span class="extras">(private)</span>
1299
-
1300
-
1301
-
1302
-
1303
-
1304
- </h3><div class="docstring">
1305
- <div class="discussion">
1306
-
1307
- <p>Performs message serialization and sends it to Cube. It builds the hash to
1308
- serialize from by <span class='object_link'><a href="#send_msg_hash-instance_method" title="MaxCube::Network::TCP::Client#send_msg_hash (method)">#send_msg_hash</a></span>, and serializes it with
1309
- <span class='object_link'><a href="../../Messages/TCP/Serializer.html#serialize_tcp_hash-instance_method" title="MaxCube::Messages::TCP::Serializer#serialize_tcp_hash (method)">Messages::TCP::Serializer#serialize_tcp_hash</a></span>.</p>
1310
-
1311
- <p>Both sent message and built hash are buffered.</p>
1312
-
1313
- <p>It catches all <span class='object_link'><a href="../../Messages/InvalidMessage.html" title="MaxCube::Messages::InvalidMessage (class)">Messages::InvalidMessage</a></span> exceptions.</p>
1314
-
1315
-
1316
- </div>
1317
- </div>
1318
- <div class="tags">
1319
- <p class="tag_title">Parameters:</p>
1320
- <ul class="param">
1321
-
1322
- <li>
1323
-
1324
- <span class='name'>type</span>
1325
-
1326
-
1327
- <span class='type'>(<tt>String</tt>)</span>
1328
-
1329
-
1330
-
1331
- &mdash;
1332
- <div class='inline'>
1333
- <p>message type.</p>
1334
- </div>
1335
-
1336
- </li>
1337
-
1338
- <li>
1339
-
1340
- <span class='name'>args</span>
1341
-
1342
-
1343
- <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1344
-
1345
-
1346
-
1347
- &mdash;
1348
- <div class='inline'>
1349
- <p>arguments from command line.</p>
1350
- </div>
1351
-
1352
- </li>
1353
-
1354
- <li>
1355
-
1356
- <span class='name'>opts</span>
1357
-
1358
-
1359
- <span class='type'>(<tt>Hash</tt>)</span>
1360
-
1361
-
1362
-
1363
- &mdash;
1364
- <div class='inline'>
1365
- <p>options that modifies interpreting of <code>args</code>.</p>
1366
- </div>
1367
-
1368
- </li>
1369
-
1370
- </ul>
1371
-
1372
-
1373
- </div><table class="source_code">
1374
- <tr>
1375
- <td>
1376
- <pre class="lines">
1377
-
1378
-
1379
- 258
1380
- 259
1381
- 260
1382
- 261
1383
- 262
1384
- 263
1385
- 264
1386
- 265
1387
- 266
1388
- 267
1389
- 268
1390
- 269
1391
- 270
1392
- 271
1393
- 272
1394
- 273
1395
- 274
1396
- 275
1397
- 276
1398
- 277
1399
- 278</pre>
1400
- </td>
1401
- <td>
1402
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 258</span>
1403
-
1404
- <span class='kw'>def</span> <span class='id identifier rubyid_send_msg'>send_msg</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1405
- <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='id identifier rubyid_send_msg_hash'>send_msg_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1406
- <span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_hash'>hash</span>
1407
-
1408
- <span class='kw'>if</span> <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='symbol'>:type</span><span class='rparen'>)</span>
1409
- <span class='kw'>unless</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span>
1410
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\nInternal hash message type mismatch: &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;</span><span class='tstring_end'>&quot;</span></span> \
1411
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> (should be &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;)</span><span class='tstring_end'>&quot;</span></span>
1412
- <span class='kw'>return</span>
1413
- <span class='kw'>end</span>
1414
- <span class='kw'>else</span>
1415
- <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span>
1416
- <span class='kw'>end</span>
1417
- <span class='id identifier rubyid_msg'>msg</span> <span class='op'>=</span> <span class='ivar'>@serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize_tcp_hash'>serialize_tcp_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
1418
-
1419
- <span class='ivar'>@buffer</span><span class='lbracket'>[</span><span class='symbol'>:sent</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_msg'>msg</span>
1420
- <span class='ivar'>@buffer</span><span class='lbracket'>[</span><span class='symbol'>:sent</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:hashes</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='lbracket'>[</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span>
1421
- <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span><span class='rparen'>)</span>
1422
- <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="../../Messages.html" title="MaxCube::Messages (module)">Messages</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Messages/InvalidMessage.html" title="MaxCube::Messages::InvalidMessage (class)">InvalidMessage</a></span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1423
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_capitalize'>capitalize</span>
1424
- <span class='kw'>end</span></pre>
1425
- </td>
1426
- </tr>
1427
- </table>
1428
- </div>
1429
-
1430
- <div class="method_details ">
1431
- <h3 class="signature " id="send_msg_hash-instance_method">
1432
-
1433
- #<strong>send_msg_hash</strong>(type, *args, **opts) &#x21d2; <tt>Hash</tt> <span class="extras">(private)</span>
1434
-
1435
-
1436
-
1437
-
1438
-
1439
- </h3><div class="docstring">
1440
- <div class="discussion">
1441
-
1442
- <p>Returns hash with contents necessary for serialization of message of given
1443
- message type. It is either built from command line <code>args</code>
1444
- (<span class='object_link'><a href="#send_msg_hash_from_keys_args-instance_method" title="MaxCube::Network::TCP::Client#send_msg_hash_from_keys_args (method)">#send_msg_hash_from_keys_args</a></span>), or loaded from YAML file
1445
- (<span class='object_link'><a href="#send_msg_hash_from_internal-instance_method" title="MaxCube::Network::TCP::Client#send_msg_hash_from_internal (method)">#send_msg_hash_from_internal</a></span>).</p>
1446
-
1447
-
1448
- </div>
1449
- </div>
1450
- <div class="tags">
1451
- <p class="tag_title">Parameters:</p>
1452
- <ul class="param">
1453
-
1454
- <li>
1455
-
1456
- <span class='name'>type</span>
1457
-
1458
-
1459
- <span class='type'>(<tt>String</tt>)</span>
1460
-
1461
-
1462
-
1463
- &mdash;
1464
- <div class='inline'>
1465
- <p>message type.</p>
1466
- </div>
1467
-
1468
- </li>
1469
-
1470
- <li>
1471
-
1472
- <span class='name'>args</span>
1473
-
1474
-
1475
- <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1476
-
1477
-
1478
-
1479
- &mdash;
1480
- <div class='inline'>
1481
- <p>arguments from command line.</p>
1482
- </div>
1483
-
1484
- </li>
1485
-
1486
- <li>
1487
-
1488
- <span class='name'>opts</span>
1489
-
1490
-
1491
- <span class='type'>(<tt>Hash</tt>)</span>
1492
-
1493
-
1494
-
1495
- &mdash;
1496
- <div class='inline'>
1497
- <p>options that modifies interpreting of <code>args</code>.</p>
1498
- </div>
1499
-
1500
- </li>
1501
-
1502
- </ul>
1503
-
1504
-
1505
-
1506
-
1507
-
1508
-
1509
-
1510
-
1511
- <p class="tag_title">Options Hash (<tt>**opts</tt>):</p>
1512
- <ul class="option">
1513
-
1514
- <li>
1515
- <span class="name">:load_only</span>
1516
- <span class="type">(<tt>Boolean</tt>)</span>
1517
- <span class="default">
1518
-
1519
- </span>
1520
-
1521
- &mdash; <div class='inline'>
1522
- <p>means that hash must be loaded from file (contents are too complex).
1523
- Specifying <span class='object_link'><a href="#ARGS_FROM_HASH-constant" title="MaxCube::Network::TCP::Client::ARGS_FROM_HASH (constant)">ARGS_FROM_HASH</a></span> is optional in this case.</p>
1524
- </div>
1525
-
1526
- </li>
1527
-
1528
- </ul>
1529
-
1530
-
1531
- <p class="tag_title">Returns:</p>
1532
- <ul class="return">
1533
-
1534
- <li>
1535
-
1536
-
1537
- <span class='type'>(<tt>Hash</tt>)</span>
1538
-
1539
-
1540
-
1541
- &mdash;
1542
- <div class='inline'>
1543
- <p>resulting hash.</p>
1544
- </div>
1545
-
1546
- </li>
1547
-
1548
- </ul>
1549
-
1550
- </div><table class="source_code">
1551
- <tr>
1552
- <td>
1553
- <pre class="lines">
1554
-
1555
-
1556
- 234
1557
- 235
1558
- 236
1559
- 237
1560
- 238
1561
- 239
1562
- 240
1563
- 241
1564
- 242
1565
- 243
1566
- 244
1567
- 245</pre>
1568
- </td>
1569
- <td>
1570
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 234</span>
1571
-
1572
- <span class='kw'>def</span> <span class='id identifier rubyid_send_msg_hash'>send_msg_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1573
- <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:load_only</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_args_from_hash?'>args_from_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
1574
- <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#ARGS_FROM_HASH-constant" title="MaxCube::Network::TCP::Client::ARGS_FROM_HASH (constant)">ARGS_FROM_HASH</a></span></span><span class='rparen'>)</span>
1575
- <span class='kw'>end</span>
1576
- <span class='kw'>return</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1577
-
1578
- <span class='kw'>if</span> <span class='id identifier rubyid_args_from_hash?'>args_from_hash?</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
1579
- <span class='kw'>return</span> <span class='id identifier rubyid_send_msg_hash_from_internal'>send_msg_hash_from_internal</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1580
- <span class='kw'>end</span>
1581
-
1582
- <span class='id identifier rubyid_send_msg_hash_from_keys_args'>send_msg_hash_from_keys_args</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1583
- <span class='kw'>end</span></pre>
1584
- </td>
1585
- </tr>
1586
- </table>
1587
- </div>
1588
-
1589
- <div class="method_details ">
1590
- <h3 class="signature " id="send_msg_hash_from_internal-instance_method">
1591
-
1592
- #<strong>send_msg_hash_from_internal</strong>(*args, **_opts) &#x21d2; <tt>Hash</tt><sup>?</sup> <span class="extras">(private)</span>
1593
-
1594
-
1595
-
1596
-
1597
-
1598
- </h3><div class="docstring">
1599
- <div class="discussion">
1600
-
1601
- <p>Returns hash via <span class='object_link'><a href="Client/Commands.html#cmd_load-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_load (method)">MaxCube::Network::TCP::Client::Commands#cmd_load</a></span>. It is used to combine sending a message with
1602
- loading a hash from file. On success and in non-persistive mode, it
1603
- simultaneously invalidates internal hash flag.</p>
1604
-
1605
-
1606
- </div>
1607
- </div>
1608
- <div class="tags">
1609
- <p class="tag_title">Parameters:</p>
1610
- <ul class="param">
1611
-
1612
- <li>
1613
-
1614
- <span class='name'>args</span>
1615
-
1616
-
1617
- <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1618
-
1619
-
1620
-
1621
- &mdash;
1622
- <div class='inline'>
1623
- <p>arguments from command line.</p>
1624
- </div>
1625
-
1626
- </li>
1627
-
1628
- </ul>
1629
-
1630
- <p class="tag_title">Returns:</p>
1631
- <ul class="return">
1632
-
1633
- <li>
1634
-
1635
-
1636
- <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
1637
-
1638
-
1639
-
1640
- &mdash;
1641
- <div class='inline'>
1642
- <p>loaded hash, or <code>nil</code> on failure.</p>
1643
- </div>
1644
-
1645
- </li>
1646
-
1647
- </ul>
1648
-
1649
- </div><table class="source_code">
1650
- <tr>
1651
- <td>
1652
- <pre class="lines">
1653
-
1654
-
1655
- 206
1656
- 207
1657
- 208
1658
- 209
1659
- 210</pre>
1660
- </td>
1661
- <td>
1662
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 206</span>
1663
-
1664
- <span class='kw'>def</span> <span class='id identifier rubyid_send_msg_hash_from_internal'>send_msg_hash_from_internal</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid__opts'>_opts</span><span class='rparen'>)</span>
1665
- <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_cmd_load'>cmd_load</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_drop'>drop</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
1666
- <span class='ivar'>@hash_set</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='ivar'>@persist</span>
1667
- <span class='ivar'>@hash</span>
1668
- <span class='kw'>end</span></pre>
1669
- </td>
1670
- </tr>
1671
- </table>
1672
- </div>
1673
-
1674
- <div class="method_details ">
1675
- <h3 class="signature " id="send_msg_hash_from_keys_args-instance_method">
1676
-
1677
- #<strong>send_msg_hash_from_keys_args</strong>(type, *args, **opts) &#x21d2; <tt>Hash</tt><sup>?</sup> <span class="extras">(private)</span>
1678
-
1679
-
1680
-
1681
-
1682
-
1683
- </h3><div class="docstring">
1684
- <div class="discussion">
1685
-
1686
- <p>Zips <code>args</code> with appropriate keys according to
1687
- <span class='object_link'><a href="../../Messages/Handler.html#msg_type_hash_keys-instance_method" title="MaxCube::Messages::Handler#msg_type_hash_keys (method)">Messages::Handler#msg_type_hash_keys</a></span> and
1688
- <span class='object_link'><a href="../../Messages/Handler.html#msg_type_hash_opt_keys-instance_method" title="MaxCube::Messages::Handler#msg_type_hash_opt_keys (method)">Messages::Handler#msg_type_hash_opt_keys</a></span>.</p>
1689
-
1690
-
1691
- </div>
1692
- </div>
1693
- <div class="tags">
1694
- <p class="tag_title">Parameters:</p>
1695
- <ul class="param">
1696
-
1697
- <li>
1698
-
1699
- <span class='name'>type</span>
1700
-
1701
-
1702
- <span class='type'>(<tt>String</tt>)</span>
1703
-
1704
-
1705
-
1706
- &mdash;
1707
- <div class='inline'>
1708
- <p>message type.</p>
1709
- </div>
1710
-
1711
- </li>
1712
-
1713
- <li>
1714
-
1715
- <span class='name'>args</span>
1716
-
1717
-
1718
- <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1719
-
1720
-
1721
-
1722
- &mdash;
1723
- <div class='inline'>
1724
- <p>arguments from command line.</p>
1725
- </div>
1726
-
1727
- </li>
1728
-
1729
- <li>
1730
-
1731
- <span class='name'>opts</span>
1732
-
1733
-
1734
- <span class='type'>(<tt>Hash</tt>)</span>
1735
-
1736
-
1737
-
1738
- &mdash;
1739
- <div class='inline'>
1740
- <p>options that modifies interpreting of <code>args</code>.</p>
1741
- </div>
1742
-
1743
- </li>
1744
-
1745
- </ul>
1746
-
1747
-
1748
-
1749
-
1750
-
1751
-
1752
-
1753
-
1754
- <p class="tag_title">Options Hash (<tt>**opts</tt>):</p>
1755
- <ul class="option">
1756
-
1757
- <li>
1758
- <span class="name">:last_array</span>
1759
- <span class="type">(<tt>Boolean</tt>)</span>
1760
- <span class="default">
1761
-
1762
- </span>
1763
-
1764
- &mdash; <div class='inline'>
1765
- <p>whether to insert all rest arguments into array that will be stored into
1766
- the last key.</p>
1767
- </div>
1768
-
1769
- </li>
1770
-
1771
- <li>
1772
- <span class="name">:array_nonempty</span>
1773
- <span class="type">(<tt>Boolean</tt>)</span>
1774
- <span class="default">
1775
-
1776
- </span>
1777
-
1778
- &mdash; <div class='inline'>
1779
- <p>whether to require <code>last_array</code> <em>not</em> to be empty.</p>
1780
- </div>
1781
-
1782
- </li>
1783
-
1784
- </ul>
1785
-
1786
-
1787
- <p class="tag_title">Returns:</p>
1788
- <ul class="return">
1789
-
1790
- <li>
1791
-
1792
-
1793
- <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
1794
-
1795
-
1796
-
1797
- &mdash;
1798
- <div class='inline'>
1799
- <p>resulting hash, or <code>nil</code> on failure.</p>
1800
- </div>
1801
-
1802
- </li>
1803
-
1804
- </ul>
1805
-
1806
- </div><table class="source_code">
1807
- <tr>
1808
- <td>
1809
- <pre class="lines">
1810
-
1811
-
1812
- 184
1813
- 185
1814
- 186
1815
- 187
1816
- 188
1817
- 189
1818
- 190
1819
- 191
1820
- 192
1821
- 193
1822
- 194
1823
- 195
1824
- 196
1825
- 197
1826
- 198</pre>
1827
- </td>
1828
- <td>
1829
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 184</span>
1830
-
1831
- <span class='kw'>def</span> <span class='id identifier rubyid_send_msg_hash_from_keys_args'>send_msg_hash_from_keys_args</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1832
- <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='ivar'>@serializer</span><span class='period'>.</span><span class='id identifier rubyid_msg_type_hash_keys'>msg_type_hash_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span> <span class='op'>+</span>
1833
- <span class='ivar'>@serializer</span><span class='period'>.</span><span class='id identifier rubyid_msg_type_hash_opt_keys'>msg_type_hash_opt_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
1834
- <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:last_array</span><span class='rbracket'>]</span>
1835
- <span class='id identifier rubyid_hash_args'>hash_args</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span>
1836
- <span class='id identifier rubyid_ary_args'>ary_args</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_drop'>drop</span><span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span>
1837
- <span class='id identifier rubyid_ary_args'>ary_args</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:array_nonempty</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_ary_args'>ary_args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1838
- <span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='id identifier rubyid_hash_args'>hash_args</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_ary_args'>ary_args</span>
1839
- <span class='kw'>end</span>
1840
- <span class='kw'>if</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>&lt;</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
1841
- <span class='kw'>return</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Additional arguments: </span><span class='tstring_end'>&#39;</span></span> \
1842
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>-</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
1843
- <span class='kw'>end</span>
1844
- <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_zip'>zip</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='rbrace'>}</span>
1845
- <span class='kw'>end</span></pre>
1846
- </td>
1847
- </tr>
1848
- </table>
1849
- </div>
1850
-
1851
- <div class="method_details ">
1852
- <h3 class="signature " id="shell-instance_method">
1853
-
1854
- #<strong>shell</strong> &#x21d2; <tt>Object</tt>
1855
-
1856
-
1857
-
1858
-
1859
-
1860
- </h3><div class="docstring">
1861
- <div class="discussion">
1862
-
1863
- <p>Interactive shell that maintains all operations with Cube. It is yet only
1864
- simple <code>STDIN</code> parser without any command history and other
1865
- features that possess all decent shells. It calls <span class='object_link'><a href="#command-instance_method" title="MaxCube::Network::TCP::Client#command (method)">#command</a></span> on every
1866
- input. It provides quite detailed usage message (<span class='object_link'><a href="Client/Commands.html#cmd_usage-instance_method" title="MaxCube::Network::TCP::Client::Commands#cmd_usage (method)">MaxCube::Network::TCP::Client::Commands#cmd_usage</a></span>).</p>
1867
-
1868
- <p>It should close gracefully from user&#39;s will, when connection closes, or
1869
- when soft interrupt appears. Calls <span class='object_link'><a href="#close-instance_method" title="MaxCube::Network::TCP::Client#close (method)">#close</a></span> when closing.</p>
1870
-
1871
-
1872
- </div>
1873
- </div>
1874
- <div class="tags">
1875
-
1876
-
1877
- </div><table class="source_code">
1878
- <tr>
1879
- <td>
1880
- <pre class="lines">
1881
-
1882
-
1883
- 104
1884
- 105
1885
- 106
1886
- 107
1887
- 108
1888
- 109
1889
- 110
1890
- 111
1891
- 112
1892
- 113
1893
- 114
1894
- 115
1895
- 116</pre>
1896
- </td>
1897
- <td>
1898
- <pre class="code"><span class="info file"># File 'lib/maxcube/network/tcp/client.rb', line 104</span>
1899
-
1900
- <span class='kw'>def</span> <span class='id identifier rubyid_shell'>shell</span>
1901
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Welcome to interactive shell!\n</span><span class='tstring_end'>&quot;</span></span> \
1902
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Type &#39;help&#39; for list of commands.\n\n</span><span class='tstring_end'>&quot;</span></span>
1903
- <span class='const'>STDIN</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
1904
- <span class='id identifier rubyid_refresh_buffer'>refresh_buffer</span>
1905
- <span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='id identifier rubyid_line'>line</span><span class='rparen'>)</span>
1906
- <span class='id identifier rubyid_puts'>puts</span>
1907
- <span class='kw'>end</span>
1908
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Interrupt</span>
1909
- <span class='kw'>rescue</span> <span class='const'>IOError</span><span class='comma'>,</span> <span class='const'>Interrupt</span>
1910
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\nClosing shell ...</span><span class='tstring_end'>&quot;</span></span>
1911
- <span class='id identifier rubyid_close'>close</span>
1912
- <span class='kw'>end</span></pre>
1913
- </td>
1914
- </tr>
1915
- </table>
1916
- </div>
1917
-
1918
- </div>
1919
-
1920
- </div>
1921
-
1922
- <div id="footer">
1923
- Generated on Fri Feb 16 13:44:02 2018 by
1924
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1925
- 0.9.12 (ruby-2.5.0).
1926
- </div>
1927
-
1928
- </div>
1929
- </body>
1930
- </html>