battlesnake 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1349 @@
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: Battlesnake::Snake
8
+
9
+ &mdash; Documentation by YARD 0.9.28
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Battlesnake::Snake";
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 (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span></span>
41
+ &raquo;
42
+ <span class="title">Snake</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: Battlesnake::Snake
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">Battlesnake::Snake</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/battlesnake/snake.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Represents a single Battlesnake player.</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+
116
+
117
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
118
+ <ul class="summary">
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#as_json-instance_method" title="#as_json (instance method)">#<strong>as_json</strong> &#x21d2; Hash </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+ <span class="note title readonly">readonly</span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'>
143
+ <p>Snake as a data structure usable by other objects.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#body-instance_method" title="#body (instance method)">#<strong>body</strong> &#x21d2; Array&lt;Location&gt; </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+ <span class="note title readonly">readonly</span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>Locations occupied by the body of the snake.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#customizations-instance_method" title="#customizations (instance method)">#<strong>customizations</strong> &#x21d2; Hash </a>
182
+
183
+
184
+
185
+ </span>
186
+
187
+
188
+
189
+
190
+ <span class="note title readonly">readonly</span>
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+ <span class="summary_desc"><div class='inline'>
201
+ <p>Display customizations.</p>
202
+ </div></span>
203
+
204
+ </li>
205
+
206
+
207
+ <li class="public ">
208
+ <span class="summary_signature">
209
+
210
+ <a href="#head-instance_method" title="#head (instance method)">#<strong>head</strong> &#x21d2; Location </a>
211
+
212
+
213
+
214
+ </span>
215
+
216
+
217
+
218
+
219
+ <span class="note title readonly">readonly</span>
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+ <span class="summary_desc"><div class='inline'>
230
+ <p>Location of snake head.</p>
231
+ </div></span>
232
+
233
+ </li>
234
+
235
+
236
+ <li class="public ">
237
+ <span class="summary_signature">
238
+
239
+ <a href="#health-instance_method" title="#health (instance method)">#<strong>health</strong> &#x21d2; Integer </a>
240
+
241
+
242
+
243
+ </span>
244
+
245
+
246
+
247
+
248
+ <span class="note title readonly">readonly</span>
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+ <span class="summary_desc"><div class='inline'>
259
+ <p>Health value between 0 and 100.</p>
260
+ </div></span>
261
+
262
+ </li>
263
+
264
+
265
+ <li class="public ">
266
+ <span class="summary_signature">
267
+
268
+ <a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> &#x21d2; String </a>
269
+
270
+
271
+
272
+ </span>
273
+
274
+
275
+
276
+
277
+ <span class="note title readonly">readonly</span>
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+ <span class="summary_desc"><div class='inline'>
288
+ <p>Unique string which identifies the player.</p>
289
+ </div></span>
290
+
291
+ </li>
292
+
293
+
294
+ <li class="public ">
295
+ <span class="summary_signature">
296
+
297
+ <a href="#latency-instance_method" title="#latency (instance method)">#<strong>latency</strong> &#x21d2; Integer </a>
298
+
299
+
300
+
301
+ </span>
302
+
303
+
304
+
305
+
306
+ <span class="note title readonly">readonly</span>
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <span class="summary_desc"><div class='inline'>
317
+ <p>Latency of given player&#39;s API, <em>nil</em> if not provided.</p>
318
+ </div></span>
319
+
320
+ </li>
321
+
322
+
323
+ <li class="public ">
324
+ <span class="summary_signature">
325
+
326
+ <a href="#length-instance_method" title="#length (instance method)">#<strong>length</strong> &#x21d2; Integer </a>
327
+
328
+
329
+
330
+ </span>
331
+
332
+
333
+
334
+
335
+ <span class="note title readonly">readonly</span>
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+ <span class="summary_desc"><div class='inline'>
346
+ <p>Number of locations occupied by snake body.</p>
347
+ </div></span>
348
+
349
+ </li>
350
+
351
+
352
+ <li class="public ">
353
+ <span class="summary_signature">
354
+
355
+ <a href="#name-instance_method" title="#name (instance method)">#<strong>name</strong> &#x21d2; String </a>
356
+
357
+
358
+
359
+ </span>
360
+
361
+
362
+
363
+
364
+ <span class="note title readonly">readonly</span>
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+ <span class="summary_desc"><div class='inline'>
375
+ <p>Name of the player.</p>
376
+ </div></span>
377
+
378
+ </li>
379
+
380
+
381
+ <li class="public ">
382
+ <span class="summary_signature">
383
+
384
+ <a href="#shout-instance_method" title="#shout (instance method)">#<strong>shout</strong> &#x21d2; String </a>
385
+
386
+
387
+
388
+ </span>
389
+
390
+
391
+
392
+
393
+ <span class="note title readonly">readonly</span>
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+ <span class="summary_desc"><div class='inline'>
404
+ <p>Message to other players.</p>
405
+ </div></span>
406
+
407
+ </li>
408
+
409
+
410
+ <li class="public ">
411
+ <span class="summary_signature">
412
+
413
+ <a href="#squad-instance_method" title="#squad (instance method)">#<strong>squad</strong> &#x21d2; String </a>
414
+
415
+
416
+
417
+ </span>
418
+
419
+
420
+
421
+
422
+ <span class="note title readonly">readonly</span>
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+ <span class="summary_desc"><div class='inline'>
433
+ <p>Squad identifer for games played with teams.</p>
434
+ </div></span>
435
+
436
+ </li>
437
+
438
+
439
+ </ul>
440
+
441
+
442
+
443
+
444
+
445
+ <h2>
446
+ Instance Method Summary
447
+ <small><a href="#" class="summary_toggle">collapse</a></small>
448
+ </h2>
449
+
450
+ <ul class="summary">
451
+
452
+ <li class="public ">
453
+ <span class="summary_signature">
454
+
455
+ <a href="#direction-instance_method" title="#direction (instance method)">#<strong>direction</strong> &#x21d2; String </a>
456
+
457
+
458
+
459
+ </span>
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+ <span class="summary_desc"><div class='inline'>
470
+ <p>The current direction the snake is facing, based on the first two segments of the body.</p>
471
+ </div></span>
472
+
473
+ </li>
474
+
475
+
476
+ <li class="public ">
477
+ <span class="summary_signature">
478
+
479
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(json_or_hash) &#x21d2; Snake </a>
480
+
481
+
482
+
483
+ </span>
484
+
485
+
486
+ <span class="note title constructor">constructor</span>
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+ <span class="summary_desc"><div class='inline'>
496
+ <p>Returns a new instance of Snake.</p>
497
+ </div></span>
498
+
499
+ </li>
500
+
501
+
502
+ </ul>
503
+
504
+
505
+ <div id="constructor_details" class="method_details_list">
506
+ <h2>Constructor Details</h2>
507
+
508
+ <div class="method_details first">
509
+ <h3 class="signature first" id="initialize-instance_method">
510
+
511
+ #<strong>initialize</strong>(json_or_hash) &#x21d2; <tt><span class='object_link'><a href="" title="Battlesnake::Snake (class)">Snake</a></span></tt>
512
+
513
+
514
+
515
+
516
+
517
+ </h3><div class="docstring">
518
+ <div class="discussion">
519
+
520
+ <p>Returns a new instance of Snake.</p>
521
+
522
+
523
+ </div>
524
+ </div>
525
+ <div class="tags">
526
+ <p class="tag_title">Parameters:</p>
527
+ <ul class="param">
528
+
529
+ <li>
530
+
531
+ <span class='name'>json_or_hash</span>
532
+
533
+
534
+ <span class='type'>(<tt>String</tt>, <tt>Hash</tt>)</span>
535
+
536
+
537
+
538
+ &mdash;
539
+ <div class='inline'>
540
+ <p>can be a hash of attributes, or a JSON string which represents such a structure.</p>
541
+ </div>
542
+
543
+ </li>
544
+
545
+ </ul>
546
+
547
+
548
+ </div><table class="source_code">
549
+ <tr>
550
+ <td>
551
+ <pre class="lines">
552
+
553
+
554
+ 47
555
+ 48
556
+ 49
557
+ 50
558
+ 51
559
+ 52
560
+ 53
561
+ 54
562
+ 55
563
+ 56
564
+ 57
565
+ 58
566
+ 59
567
+ 60
568
+ 61</pre>
569
+ </td>
570
+ <td>
571
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 47</span>
572
+
573
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_json_or_hash'>json_or_hash</span><span class='rparen'>)</span>
574
+ <span class='ivar'>@as_json</span> <span class='op'>=</span> <span class='id identifier rubyid_json_or_hash'>json_or_hash</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_json_or_hash'>json_or_hash</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_json_or_hash'>json_or_hash</span>
575
+
576
+ <span class='ivar'>@id</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
577
+ <span class='ivar'>@name</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>name</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
578
+ <span class='ivar'>@latency</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>latency</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>latency</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
579
+ <span class='ivar'>@health</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>health</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
580
+ <span class='ivar'>@length</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>length</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
581
+ <span class='ivar'>@shout</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>shout</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
582
+ <span class='ivar'>@squad</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>squad</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
583
+ <span class='ivar'>@customizations</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>customizations</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
584
+
585
+ <span class='ivar'>@body</span> <span class='op'>=</span> <span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>body</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_coords'>coords</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_coords'>coords</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
586
+ <span class='ivar'>@head</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@as_json</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>head</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
587
+ <span class='kw'>end</span></pre>
588
+ </td>
589
+ </tr>
590
+ </table>
591
+ </div>
592
+
593
+ </div>
594
+
595
+ <div id="instance_attr_details" class="attr_details">
596
+ <h2>Instance Attribute Details</h2>
597
+
598
+
599
+ <span id=""></span>
600
+ <div class="method_details first">
601
+ <h3 class="signature first" id="as_json-instance_method">
602
+
603
+ #<strong>as_json</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
604
+
605
+
606
+
607
+
608
+
609
+ </h3><div class="docstring">
610
+ <div class="discussion">
611
+
612
+ <p>Returns snake as a data structure usable by other objects.</p>
613
+
614
+
615
+ </div>
616
+ </div>
617
+ <div class="tags">
618
+
619
+ <p class="tag_title">Returns:</p>
620
+ <ul class="return">
621
+
622
+ <li>
623
+
624
+
625
+ <span class='type'>(<tt>Hash</tt>)</span>
626
+
627
+
628
+
629
+ &mdash;
630
+ <div class='inline'>
631
+ <p>snake as a data structure usable by other objects.</p>
632
+ </div>
633
+
634
+ </li>
635
+
636
+ </ul>
637
+
638
+ </div><table class="source_code">
639
+ <tr>
640
+ <td>
641
+ <pre class="lines">
642
+
643
+
644
+ 8
645
+ 9
646
+ 10</pre>
647
+ </td>
648
+ <td>
649
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 8</span>
650
+
651
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span>
652
+ <span class='ivar'>@as_json</span>
653
+ <span class='kw'>end</span></pre>
654
+ </td>
655
+ </tr>
656
+ </table>
657
+ </div>
658
+
659
+
660
+ <span id=""></span>
661
+ <div class="method_details ">
662
+ <h3 class="signature " id="body-instance_method">
663
+
664
+ #<strong>body</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt> <span class="extras">(readonly)</span>
665
+
666
+
667
+
668
+
669
+
670
+ </h3><div class="docstring">
671
+ <div class="discussion">
672
+
673
+ <p>Returns locations occupied by the body of the snake.</p>
674
+
675
+
676
+ </div>
677
+ </div>
678
+ <div class="tags">
679
+
680
+ <p class="tag_title">Returns:</p>
681
+ <ul class="return">
682
+
683
+ <li>
684
+
685
+
686
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>)</span>
687
+
688
+
689
+
690
+ &mdash;
691
+ <div class='inline'>
692
+ <p>locations occupied by the body of the snake.</p>
693
+ </div>
694
+
695
+ </li>
696
+
697
+ </ul>
698
+
699
+ </div><table class="source_code">
700
+ <tr>
701
+ <td>
702
+ <pre class="lines">
703
+
704
+
705
+ 17
706
+ 18
707
+ 19</pre>
708
+ </td>
709
+ <td>
710
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 17</span>
711
+
712
+ <span class='kw'>def</span> <span class='id identifier rubyid_body'>body</span>
713
+ <span class='ivar'>@body</span>
714
+ <span class='kw'>end</span></pre>
715
+ </td>
716
+ </tr>
717
+ </table>
718
+ </div>
719
+
720
+
721
+ <span id=""></span>
722
+ <div class="method_details ">
723
+ <h3 class="signature " id="customizations-instance_method">
724
+
725
+ #<strong>customizations</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
726
+
727
+
728
+
729
+
730
+
731
+ </h3><div class="docstring">
732
+ <div class="discussion">
733
+
734
+ <p>Returns display customizations.</p>
735
+
736
+
737
+ </div>
738
+ </div>
739
+ <div class="tags">
740
+
741
+ <p class="tag_title">Returns:</p>
742
+ <ul class="return">
743
+
744
+ <li>
745
+
746
+
747
+ <span class='type'>(<tt>Hash</tt>)</span>
748
+
749
+
750
+
751
+ &mdash;
752
+ <div class='inline'>
753
+ <p>display customizations.</p>
754
+ </div>
755
+
756
+ </li>
757
+
758
+ </ul>
759
+
760
+ </div><table class="source_code">
761
+ <tr>
762
+ <td>
763
+ <pre class="lines">
764
+
765
+
766
+ 38
767
+ 39
768
+ 40</pre>
769
+ </td>
770
+ <td>
771
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 38</span>
772
+
773
+ <span class='kw'>def</span> <span class='id identifier rubyid_customizations'>customizations</span>
774
+ <span class='ivar'>@customizations</span>
775
+ <span class='kw'>end</span></pre>
776
+ </td>
777
+ </tr>
778
+ </table>
779
+ </div>
780
+
781
+
782
+ <span id=""></span>
783
+ <div class="method_details ">
784
+ <h3 class="signature " id="head-instance_method">
785
+
786
+ #<strong>head</strong> &#x21d2; <tt><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></tt> <span class="extras">(readonly)</span>
787
+
788
+
789
+
790
+
791
+
792
+ </h3><div class="docstring">
793
+ <div class="discussion">
794
+
795
+ <p>Returns location of snake head. Should be the same as <a href="0">body</a>.</p>
796
+
797
+
798
+ </div>
799
+ </div>
800
+ <div class="tags">
801
+
802
+ <p class="tag_title">Returns:</p>
803
+ <ul class="return">
804
+
805
+ <li>
806
+
807
+
808
+ <span class='type'>(<tt><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></tt>)</span>
809
+
810
+
811
+
812
+ &mdash;
813
+ <div class='inline'>
814
+ <p>location of snake head. Should be the same as <a href="0">body</a>.</p>
815
+ </div>
816
+
817
+ </li>
818
+
819
+ </ul>
820
+
821
+ </div><table class="source_code">
822
+ <tr>
823
+ <td>
824
+ <pre class="lines">
825
+
826
+
827
+ 26
828
+ 27
829
+ 28</pre>
830
+ </td>
831
+ <td>
832
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 26</span>
833
+
834
+ <span class='kw'>def</span> <span class='id identifier rubyid_head'>head</span>
835
+ <span class='ivar'>@head</span>
836
+ <span class='kw'>end</span></pre>
837
+ </td>
838
+ </tr>
839
+ </table>
840
+ </div>
841
+
842
+
843
+ <span id=""></span>
844
+ <div class="method_details ">
845
+ <h3 class="signature " id="health-instance_method">
846
+
847
+ #<strong>health</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
848
+
849
+
850
+
851
+
852
+
853
+ </h3><div class="docstring">
854
+ <div class="discussion">
855
+
856
+ <p>Returns health value between 0 and 100.</p>
857
+
858
+
859
+ </div>
860
+ </div>
861
+ <div class="tags">
862
+
863
+ <p class="tag_title">Returns:</p>
864
+ <ul class="return">
865
+
866
+ <li>
867
+
868
+
869
+ <span class='type'>(<tt>Integer</tt>)</span>
870
+
871
+
872
+
873
+ &mdash;
874
+ <div class='inline'>
875
+ <p>health value between 0 and 100.</p>
876
+ </div>
877
+
878
+ </li>
879
+
880
+ </ul>
881
+
882
+ </div><table class="source_code">
883
+ <tr>
884
+ <td>
885
+ <pre class="lines">
886
+
887
+
888
+ 23
889
+ 24
890
+ 25</pre>
891
+ </td>
892
+ <td>
893
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 23</span>
894
+
895
+ <span class='kw'>def</span> <span class='id identifier rubyid_health'>health</span>
896
+ <span class='ivar'>@health</span>
897
+ <span class='kw'>end</span></pre>
898
+ </td>
899
+ </tr>
900
+ </table>
901
+ </div>
902
+
903
+
904
+ <span id=""></span>
905
+ <div class="method_details ">
906
+ <h3 class="signature " id="id-instance_method">
907
+
908
+ #<strong>id</strong> &#x21d2; <tt>String</tt> <span class="extras">(readonly)</span>
909
+
910
+
911
+
912
+
913
+
914
+ </h3><div class="docstring">
915
+ <div class="discussion">
916
+
917
+ <p>Returns unique string which identifies the player.</p>
918
+
919
+
920
+ </div>
921
+ </div>
922
+ <div class="tags">
923
+
924
+ <p class="tag_title">Returns:</p>
925
+ <ul class="return">
926
+
927
+ <li>
928
+
929
+
930
+ <span class='type'>(<tt>String</tt>)</span>
931
+
932
+
933
+
934
+ &mdash;
935
+ <div class='inline'>
936
+ <p>unique string which identifies the player.</p>
937
+ </div>
938
+
939
+ </li>
940
+
941
+ </ul>
942
+
943
+ </div><table class="source_code">
944
+ <tr>
945
+ <td>
946
+ <pre class="lines">
947
+
948
+
949
+ 11
950
+ 12
951
+ 13</pre>
952
+ </td>
953
+ <td>
954
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 11</span>
955
+
956
+ <span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span>
957
+ <span class='ivar'>@id</span>
958
+ <span class='kw'>end</span></pre>
959
+ </td>
960
+ </tr>
961
+ </table>
962
+ </div>
963
+
964
+
965
+ <span id=""></span>
966
+ <div class="method_details ">
967
+ <h3 class="signature " id="latency-instance_method">
968
+
969
+ #<strong>latency</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
970
+
971
+
972
+
973
+
974
+
975
+ </h3><div class="docstring">
976
+ <div class="discussion">
977
+
978
+ <p>Returns latency of given player&#39;s API, <em>nil</em> if not provided.</p>
979
+
980
+
981
+ </div>
982
+ </div>
983
+ <div class="tags">
984
+
985
+ <p class="tag_title">Returns:</p>
986
+ <ul class="return">
987
+
988
+ <li>
989
+
990
+
991
+ <span class='type'>(<tt>Integer</tt>)</span>
992
+
993
+
994
+
995
+ &mdash;
996
+ <div class='inline'>
997
+ <p>latency of given player&#39;s API, <em>nil</em> if not provided.</p>
998
+ </div>
999
+
1000
+ </li>
1001
+
1002
+ </ul>
1003
+
1004
+ </div><table class="source_code">
1005
+ <tr>
1006
+ <td>
1007
+ <pre class="lines">
1008
+
1009
+
1010
+ 20
1011
+ 21
1012
+ 22</pre>
1013
+ </td>
1014
+ <td>
1015
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 20</span>
1016
+
1017
+ <span class='kw'>def</span> <span class='id identifier rubyid_latency'>latency</span>
1018
+ <span class='ivar'>@latency</span>
1019
+ <span class='kw'>end</span></pre>
1020
+ </td>
1021
+ </tr>
1022
+ </table>
1023
+ </div>
1024
+
1025
+
1026
+ <span id=""></span>
1027
+ <div class="method_details ">
1028
+ <h3 class="signature " id="length-instance_method">
1029
+
1030
+ #<strong>length</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+ </h3><div class="docstring">
1037
+ <div class="discussion">
1038
+
1039
+ <p>Returns number of locations occupied by snake body.</p>
1040
+
1041
+
1042
+ </div>
1043
+ </div>
1044
+ <div class="tags">
1045
+
1046
+ <p class="tag_title">Returns:</p>
1047
+ <ul class="return">
1048
+
1049
+ <li>
1050
+
1051
+
1052
+ <span class='type'>(<tt>Integer</tt>)</span>
1053
+
1054
+
1055
+
1056
+ &mdash;
1057
+ <div class='inline'>
1058
+ <p>number of locations occupied by snake body.</p>
1059
+ </div>
1060
+
1061
+ </li>
1062
+
1063
+ </ul>
1064
+
1065
+ </div><table class="source_code">
1066
+ <tr>
1067
+ <td>
1068
+ <pre class="lines">
1069
+
1070
+
1071
+ 29
1072
+ 30
1073
+ 31</pre>
1074
+ </td>
1075
+ <td>
1076
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 29</span>
1077
+
1078
+ <span class='kw'>def</span> <span class='id identifier rubyid_length'>length</span>
1079
+ <span class='ivar'>@length</span>
1080
+ <span class='kw'>end</span></pre>
1081
+ </td>
1082
+ </tr>
1083
+ </table>
1084
+ </div>
1085
+
1086
+
1087
+ <span id=""></span>
1088
+ <div class="method_details ">
1089
+ <h3 class="signature " id="name-instance_method">
1090
+
1091
+ #<strong>name</strong> &#x21d2; <tt>String</tt> <span class="extras">(readonly)</span>
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+ </h3><div class="docstring">
1098
+ <div class="discussion">
1099
+
1100
+ <p>Returns name of the player.</p>
1101
+
1102
+
1103
+ </div>
1104
+ </div>
1105
+ <div class="tags">
1106
+
1107
+ <p class="tag_title">Returns:</p>
1108
+ <ul class="return">
1109
+
1110
+ <li>
1111
+
1112
+
1113
+ <span class='type'>(<tt>String</tt>)</span>
1114
+
1115
+
1116
+
1117
+ &mdash;
1118
+ <div class='inline'>
1119
+ <p>name of the player.</p>
1120
+ </div>
1121
+
1122
+ </li>
1123
+
1124
+ </ul>
1125
+
1126
+ </div><table class="source_code">
1127
+ <tr>
1128
+ <td>
1129
+ <pre class="lines">
1130
+
1131
+
1132
+ 14
1133
+ 15
1134
+ 16</pre>
1135
+ </td>
1136
+ <td>
1137
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 14</span>
1138
+
1139
+ <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
1140
+ <span class='ivar'>@name</span>
1141
+ <span class='kw'>end</span></pre>
1142
+ </td>
1143
+ </tr>
1144
+ </table>
1145
+ </div>
1146
+
1147
+
1148
+ <span id=""></span>
1149
+ <div class="method_details ">
1150
+ <h3 class="signature " id="shout-instance_method">
1151
+
1152
+ #<strong>shout</strong> &#x21d2; <tt>String</tt> <span class="extras">(readonly)</span>
1153
+
1154
+
1155
+
1156
+
1157
+
1158
+ </h3><div class="docstring">
1159
+ <div class="discussion">
1160
+
1161
+ <p>Returns message to other players.</p>
1162
+
1163
+
1164
+ </div>
1165
+ </div>
1166
+ <div class="tags">
1167
+
1168
+ <p class="tag_title">Returns:</p>
1169
+ <ul class="return">
1170
+
1171
+ <li>
1172
+
1173
+
1174
+ <span class='type'>(<tt>String</tt>)</span>
1175
+
1176
+
1177
+
1178
+ &mdash;
1179
+ <div class='inline'>
1180
+ <p>message to other players.</p>
1181
+ </div>
1182
+
1183
+ </li>
1184
+
1185
+ </ul>
1186
+
1187
+ </div><table class="source_code">
1188
+ <tr>
1189
+ <td>
1190
+ <pre class="lines">
1191
+
1192
+
1193
+ 32
1194
+ 33
1195
+ 34</pre>
1196
+ </td>
1197
+ <td>
1198
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 32</span>
1199
+
1200
+ <span class='kw'>def</span> <span class='id identifier rubyid_shout'>shout</span>
1201
+ <span class='ivar'>@shout</span>
1202
+ <span class='kw'>end</span></pre>
1203
+ </td>
1204
+ </tr>
1205
+ </table>
1206
+ </div>
1207
+
1208
+
1209
+ <span id=""></span>
1210
+ <div class="method_details ">
1211
+ <h3 class="signature " id="squad-instance_method">
1212
+
1213
+ #<strong>squad</strong> &#x21d2; <tt>String</tt> <span class="extras">(readonly)</span>
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+ </h3><div class="docstring">
1220
+ <div class="discussion">
1221
+
1222
+ <p>Returns squad identifer for games played with teams.</p>
1223
+
1224
+
1225
+ </div>
1226
+ </div>
1227
+ <div class="tags">
1228
+
1229
+ <p class="tag_title">Returns:</p>
1230
+ <ul class="return">
1231
+
1232
+ <li>
1233
+
1234
+
1235
+ <span class='type'>(<tt>String</tt>)</span>
1236
+
1237
+
1238
+
1239
+ &mdash;
1240
+ <div class='inline'>
1241
+ <p>squad identifer for games played with teams.</p>
1242
+ </div>
1243
+
1244
+ </li>
1245
+
1246
+ </ul>
1247
+
1248
+ </div><table class="source_code">
1249
+ <tr>
1250
+ <td>
1251
+ <pre class="lines">
1252
+
1253
+
1254
+ 35
1255
+ 36
1256
+ 37</pre>
1257
+ </td>
1258
+ <td>
1259
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 35</span>
1260
+
1261
+ <span class='kw'>def</span> <span class='id identifier rubyid_squad'>squad</span>
1262
+ <span class='ivar'>@squad</span>
1263
+ <span class='kw'>end</span></pre>
1264
+ </td>
1265
+ </tr>
1266
+ </table>
1267
+ </div>
1268
+
1269
+ </div>
1270
+
1271
+
1272
+ <div id="instance_method_details" class="method_details_list">
1273
+ <h2>Instance Method Details</h2>
1274
+
1275
+
1276
+ <div class="method_details first">
1277
+ <h3 class="signature first" id="direction-instance_method">
1278
+
1279
+ #<strong>direction</strong> &#x21d2; <tt>String</tt>
1280
+
1281
+
1282
+
1283
+
1284
+
1285
+ </h3><div class="docstring">
1286
+ <div class="discussion">
1287
+
1288
+ <p>The current direction the snake is facing, based on the first two segments of the body. If snake only has a head, no direction can be determined, so <em>nil</em> is returned.</p>
1289
+
1290
+
1291
+ </div>
1292
+ </div>
1293
+ <div class="tags">
1294
+
1295
+ <p class="tag_title">Returns:</p>
1296
+ <ul class="return">
1297
+
1298
+ <li>
1299
+
1300
+
1301
+ <span class='type'>(<tt>String</tt>)</span>
1302
+
1303
+
1304
+
1305
+ &mdash;
1306
+ <div class='inline'>
1307
+ <p>one of (up, down, left, right)</p>
1308
+ </div>
1309
+
1310
+ </li>
1311
+
1312
+ </ul>
1313
+
1314
+ </div><table class="source_code">
1315
+ <tr>
1316
+ <td>
1317
+ <pre class="lines">
1318
+
1319
+
1320
+ 69
1321
+ 70
1322
+ 71
1323
+ 72</pre>
1324
+ </td>
1325
+ <td>
1326
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/snake.rb', line 69</span>
1327
+
1328
+ <span class='kw'>def</span> <span class='id identifier rubyid_direction'>direction</span>
1329
+ <span class='kw'>return</span> <span class='ivar'>@direction</span> <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='ivar'>@direction</span><span class='rparen'>)</span>
1330
+ <span class='ivar'>@direction</span> <span class='op'>=</span> <span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>1</span> <span class='op'>?</span> <span class='id identifier rubyid_body'>body</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_direction'>direction</span><span class='lparen'>(</span><span class='id identifier rubyid_head'>head</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
1331
+ <span class='kw'>end</span></pre>
1332
+ </td>
1333
+ </tr>
1334
+ </table>
1335
+ </div>
1336
+
1337
+ </div>
1338
+
1339
+ </div>
1340
+
1341
+ <div id="footer">
1342
+ Generated on Fri Nov 4 14:55:40 2022 by
1343
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1344
+ 0.9.28 (ruby-2.7.2).
1345
+ </div>
1346
+
1347
+ </div>
1348
+ </body>
1349
+ </html>