battlesnake 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e268dabbc4bbf5559d5ee84247f0dd4f69c8f4b264da6302d4a7c4ed164a1f4c
4
- data.tar.gz: 3f9cdd282e002ba8d0c7764c56077335514ee042702c7151d7e98b50ef3d831f
3
+ metadata.gz: 9063a25174a53025eafe1531362e7936d76642ee9bf277ffcf3fd991ee42748f
4
+ data.tar.gz: bb1f156bf82db23929080a0a1522115f2b8f919856aa927b15e759c07b3fcd0d
5
5
  SHA512:
6
- metadata.gz: 3b8db625deaf846d5abf90e3b8aa313b690761c0aa60830600dc454c687ca698a4e88c854f2cdec1aa4d4bedd816154f78a763bde2ea8ce96377a8a9c8b96c36
7
- data.tar.gz: 970ce4f77db5bfc5c080c7ad61f4d7f510d2404423554b808b36300de4a8afec7dbfa077c981a6db2c04f0d12e739a6894d443060874f2dbd92161d1a247d3b4
6
+ metadata.gz: 47f22b9584800f6f45ad171691d3bb479ce091f1bc6c4baef6a7fe12b64b63f61d0de68e95d1b096207cd177fbff5a8b7332a961c74919c99894d98b1427570c
7
+ data.tar.gz: f5eef7cc0ffb4bffb971c0932e7fcc96ff0ba19c3e5222575c60d97f2f9ab7c042367d97b5fa45aa05e22241a0fe1f45cfe3853c9edd89c2c127fd0e4afac392
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- battlesnake (0.1.0)
4
+ battlesnake (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,798 @@
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::Board
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::Board";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span></span>
41
+ &raquo;
42
+ <span class="title">Board</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::Board
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::Board</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/board.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 iteration (turn) of a Battlesnake board during gameplay.</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>Board 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="#food-instance_method" title="#food (instance method)">#<strong>food</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>List of food location objects.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#hazards-instance_method" title="#hazards (instance method)">#<strong>hazards</strong> &#x21d2; Array&lt;Location&gt; </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>List of hazard location objects.</p>
202
+ </div></span>
203
+
204
+ </li>
205
+
206
+
207
+ <li class="public ">
208
+ <span class="summary_signature">
209
+
210
+ <a href="#height-instance_method" title="#height (instance method)">#<strong>height</strong> &#x21d2; Integer </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>Height of the board.</p>
231
+ </div></span>
232
+
233
+ </li>
234
+
235
+
236
+ <li class="public ">
237
+ <span class="summary_signature">
238
+
239
+ <a href="#snakes-instance_method" title="#snakes (instance method)">#<strong>snakes</strong> &#x21d2; Array&lt;Snake&gt; </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>List of snake objects.</p>
260
+ </div></span>
261
+
262
+ </li>
263
+
264
+
265
+ <li class="public ">
266
+ <span class="summary_signature">
267
+
268
+ <a href="#width-instance_method" title="#width (instance method)">#<strong>width</strong> &#x21d2; Integer </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>Width of the board.</p>
289
+ </div></span>
290
+
291
+ </li>
292
+
293
+
294
+ </ul>
295
+
296
+
297
+
298
+
299
+
300
+ <h2>
301
+ Instance Method Summary
302
+ <small><a href="#" class="summary_toggle">collapse</a></small>
303
+ </h2>
304
+
305
+ <ul class="summary">
306
+
307
+ <li class="public ">
308
+ <span class="summary_signature">
309
+
310
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(json_or_hash) &#x21d2; Board </a>
311
+
312
+
313
+
314
+ </span>
315
+
316
+
317
+ <span class="note title constructor">constructor</span>
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+ <span class="summary_desc"><div class='inline'>
327
+ <p>Returns a new instance of Board.</p>
328
+ </div></span>
329
+
330
+ </li>
331
+
332
+
333
+ </ul>
334
+
335
+
336
+ <div id="constructor_details" class="method_details_list">
337
+ <h2>Constructor Details</h2>
338
+
339
+ <div class="method_details first">
340
+ <h3 class="signature first" id="initialize-instance_method">
341
+
342
+ #<strong>initialize</strong>(json_or_hash) &#x21d2; <tt><span class='object_link'><a href="" title="Battlesnake::Board (class)">Board</a></span></tt>
343
+
344
+
345
+
346
+
347
+
348
+ </h3><div class="docstring">
349
+ <div class="discussion">
350
+
351
+ <p>Returns a new instance of Board.</p>
352
+
353
+
354
+ </div>
355
+ </div>
356
+ <div class="tags">
357
+ <p class="tag_title">Parameters:</p>
358
+ <ul class="param">
359
+
360
+ <li>
361
+
362
+ <span class='name'>json_or_hash</span>
363
+
364
+
365
+ <span class='type'>(<tt>String</tt>, <tt>Hash</tt>)</span>
366
+
367
+
368
+
369
+ &mdash;
370
+ <div class='inline'>
371
+ <p>can be a hash of attributes, or a JSON string which represents such a structure.</p>
372
+ </div>
373
+
374
+ </li>
375
+
376
+ </ul>
377
+
378
+
379
+ </div><table class="source_code">
380
+ <tr>
381
+ <td>
382
+ <pre class="lines">
383
+
384
+
385
+ 32
386
+ 33
387
+ 34
388
+ 35
389
+ 36
390
+ 37
391
+ 38
392
+ 39
393
+ 40
394
+ 41</pre>
395
+ </td>
396
+ <td>
397
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 32</span>
398
+
399
+ <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>
400
+ <span class='id identifier rubyid_data'>data</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>
401
+
402
+ <span class='ivar'>@as_json</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
403
+ <span class='ivar'>@height</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>height</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
404
+ <span class='ivar'>@width</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>width</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
405
+ <span class='ivar'>@snakes</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>snakes</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_attrs'>attrs</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="Snake.html" title="Battlesnake::Snake (class)">Snake</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Snake.html#initialize-instance_method" title="Battlesnake::Snake#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
406
+ <span class='ivar'>@food</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>food</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_attrs'>attrs</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_attrs'>attrs</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
407
+ <span class='ivar'>@hazards</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>hazards</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_attrs'>attrs</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_attrs'>attrs</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
408
+ <span class='kw'>end</span></pre>
409
+ </td>
410
+ </tr>
411
+ </table>
412
+ </div>
413
+
414
+ </div>
415
+
416
+ <div id="instance_attr_details" class="attr_details">
417
+ <h2>Instance Attribute Details</h2>
418
+
419
+
420
+ <span id=""></span>
421
+ <div class="method_details first">
422
+ <h3 class="signature first" id="as_json-instance_method">
423
+
424
+ #<strong>as_json</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
425
+
426
+
427
+
428
+
429
+
430
+ </h3><div class="docstring">
431
+ <div class="discussion">
432
+
433
+ <p>Returns board as a data structure usable by other objects.</p>
434
+
435
+
436
+ </div>
437
+ </div>
438
+ <div class="tags">
439
+
440
+ <p class="tag_title">Returns:</p>
441
+ <ul class="return">
442
+
443
+ <li>
444
+
445
+
446
+ <span class='type'>(<tt>Hash</tt>)</span>
447
+
448
+
449
+
450
+ &mdash;
451
+ <div class='inline'>
452
+ <p>board as a data structure usable by other objects.</p>
453
+ </div>
454
+
455
+ </li>
456
+
457
+ </ul>
458
+
459
+ </div><table class="source_code">
460
+ <tr>
461
+ <td>
462
+ <pre class="lines">
463
+
464
+
465
+ 8
466
+ 9
467
+ 10</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 8</span>
471
+
472
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span>
473
+ <span class='ivar'>@as_json</span>
474
+ <span class='kw'>end</span></pre>
475
+ </td>
476
+ </tr>
477
+ </table>
478
+ </div>
479
+
480
+
481
+ <span id=""></span>
482
+ <div class="method_details ">
483
+ <h3 class="signature " id="food-instance_method">
484
+
485
+ #<strong>food</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>
486
+
487
+
488
+
489
+
490
+
491
+ </h3><div class="docstring">
492
+ <div class="discussion">
493
+
494
+ <p>Returns list of food location objects.</p>
495
+
496
+
497
+ </div>
498
+ </div>
499
+ <div class="tags">
500
+
501
+ <p class="tag_title">Returns:</p>
502
+ <ul class="return">
503
+
504
+ <li>
505
+
506
+
507
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>)</span>
508
+
509
+
510
+
511
+ &mdash;
512
+ <div class='inline'>
513
+ <p>list of food location objects</p>
514
+ </div>
515
+
516
+ </li>
517
+
518
+ </ul>
519
+
520
+ </div><table class="source_code">
521
+ <tr>
522
+ <td>
523
+ <pre class="lines">
524
+
525
+
526
+ 20
527
+ 21
528
+ 22</pre>
529
+ </td>
530
+ <td>
531
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 20</span>
532
+
533
+ <span class='kw'>def</span> <span class='id identifier rubyid_food'>food</span>
534
+ <span class='ivar'>@food</span>
535
+ <span class='kw'>end</span></pre>
536
+ </td>
537
+ </tr>
538
+ </table>
539
+ </div>
540
+
541
+
542
+ <span id=""></span>
543
+ <div class="method_details ">
544
+ <h3 class="signature " id="hazards-instance_method">
545
+
546
+ #<strong>hazards</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>
547
+
548
+
549
+
550
+
551
+
552
+ </h3><div class="docstring">
553
+ <div class="discussion">
554
+
555
+ <p>Returns list of hazard location objects.</p>
556
+
557
+
558
+ </div>
559
+ </div>
560
+ <div class="tags">
561
+
562
+ <p class="tag_title">Returns:</p>
563
+ <ul class="return">
564
+
565
+ <li>
566
+
567
+
568
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>)</span>
569
+
570
+
571
+
572
+ &mdash;
573
+ <div class='inline'>
574
+ <p>list of hazard location objects</p>
575
+ </div>
576
+
577
+ </li>
578
+
579
+ </ul>
580
+
581
+ </div><table class="source_code">
582
+ <tr>
583
+ <td>
584
+ <pre class="lines">
585
+
586
+
587
+ 23
588
+ 24
589
+ 25</pre>
590
+ </td>
591
+ <td>
592
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 23</span>
593
+
594
+ <span class='kw'>def</span> <span class='id identifier rubyid_hazards'>hazards</span>
595
+ <span class='ivar'>@hazards</span>
596
+ <span class='kw'>end</span></pre>
597
+ </td>
598
+ </tr>
599
+ </table>
600
+ </div>
601
+
602
+
603
+ <span id=""></span>
604
+ <div class="method_details ">
605
+ <h3 class="signature " id="height-instance_method">
606
+
607
+ #<strong>height</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
608
+
609
+
610
+
611
+
612
+
613
+ </h3><div class="docstring">
614
+ <div class="discussion">
615
+
616
+ <p>Returns height of the board.</p>
617
+
618
+
619
+ </div>
620
+ </div>
621
+ <div class="tags">
622
+
623
+ <p class="tag_title">Returns:</p>
624
+ <ul class="return">
625
+
626
+ <li>
627
+
628
+
629
+ <span class='type'>(<tt>Integer</tt>)</span>
630
+
631
+
632
+
633
+ &mdash;
634
+ <div class='inline'>
635
+ <p>height of the board</p>
636
+ </div>
637
+
638
+ </li>
639
+
640
+ </ul>
641
+
642
+ </div><table class="source_code">
643
+ <tr>
644
+ <td>
645
+ <pre class="lines">
646
+
647
+
648
+ 11
649
+ 12
650
+ 13</pre>
651
+ </td>
652
+ <td>
653
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 11</span>
654
+
655
+ <span class='kw'>def</span> <span class='id identifier rubyid_height'>height</span>
656
+ <span class='ivar'>@height</span>
657
+ <span class='kw'>end</span></pre>
658
+ </td>
659
+ </tr>
660
+ </table>
661
+ </div>
662
+
663
+
664
+ <span id=""></span>
665
+ <div class="method_details ">
666
+ <h3 class="signature " id="snakes-instance_method">
667
+
668
+ #<strong>snakes</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>&gt;</tt> <span class="extras">(readonly)</span>
669
+
670
+
671
+
672
+
673
+
674
+ </h3><div class="docstring">
675
+ <div class="discussion">
676
+
677
+ <p>Returns list of snake objects.</p>
678
+
679
+
680
+ </div>
681
+ </div>
682
+ <div class="tags">
683
+
684
+ <p class="tag_title">Returns:</p>
685
+ <ul class="return">
686
+
687
+ <li>
688
+
689
+
690
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>&gt;</tt>)</span>
691
+
692
+
693
+
694
+ &mdash;
695
+ <div class='inline'>
696
+ <p>list of snake objects</p>
697
+ </div>
698
+
699
+ </li>
700
+
701
+ </ul>
702
+
703
+ </div><table class="source_code">
704
+ <tr>
705
+ <td>
706
+ <pre class="lines">
707
+
708
+
709
+ 17
710
+ 18
711
+ 19</pre>
712
+ </td>
713
+ <td>
714
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 17</span>
715
+
716
+ <span class='kw'>def</span> <span class='id identifier rubyid_snakes'>snakes</span>
717
+ <span class='ivar'>@snakes</span>
718
+ <span class='kw'>end</span></pre>
719
+ </td>
720
+ </tr>
721
+ </table>
722
+ </div>
723
+
724
+
725
+ <span id=""></span>
726
+ <div class="method_details ">
727
+ <h3 class="signature " id="width-instance_method">
728
+
729
+ #<strong>width</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
730
+
731
+
732
+
733
+
734
+
735
+ </h3><div class="docstring">
736
+ <div class="discussion">
737
+
738
+ <p>Returns width of the board.</p>
739
+
740
+
741
+ </div>
742
+ </div>
743
+ <div class="tags">
744
+
745
+ <p class="tag_title">Returns:</p>
746
+ <ul class="return">
747
+
748
+ <li>
749
+
750
+
751
+ <span class='type'>(<tt>Integer</tt>)</span>
752
+
753
+
754
+
755
+ &mdash;
756
+ <div class='inline'>
757
+ <p>width of the board</p>
758
+ </div>
759
+
760
+ </li>
761
+
762
+ </ul>
763
+
764
+ </div><table class="source_code">
765
+ <tr>
766
+ <td>
767
+ <pre class="lines">
768
+
769
+
770
+ 14
771
+ 15
772
+ 16</pre>
773
+ </td>
774
+ <td>
775
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 14</span>
776
+
777
+ <span class='kw'>def</span> <span class='id identifier rubyid_width'>width</span>
778
+ <span class='ivar'>@width</span>
779
+ <span class='kw'>end</span></pre>
780
+ </td>
781
+ </tr>
782
+ </table>
783
+ </div>
784
+
785
+ </div>
786
+
787
+
788
+ </div>
789
+
790
+ <div id="footer">
791
+ Generated on Fri Nov 4 19:07:50 2022 by
792
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
793
+ 0.9.28 (ruby-2.7.2).
794
+ </div>
795
+
796
+ </div>
797
+ </body>
798
+ </html>
@@ -125,7 +125,7 @@
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Fri Nov 4 14:55:40 2022 by
128
+ Generated on Fri Nov 4 19:07:49 2022 by
129
129
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
130
  0.9.28 (ruby-2.7.2).
131
131
  </div>
@@ -995,7 +995,7 @@
995
995
  </div>
996
996
 
997
997
  <div id="footer">
998
- Generated on Fri Nov 4 14:55:40 2022 by
998
+ Generated on Fri Nov 4 19:07:50 2022 by
999
999
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1000
1000
  0.9.28 (ruby-2.7.2).
1001
1001
  </div>
@@ -1339,7 +1339,7 @@
1339
1339
  </div>
1340
1340
 
1341
1341
  <div id="footer">
1342
- Generated on Fri Nov 4 14:55:40 2022 by
1342
+ Generated on Fri Nov 4 19:07:50 2022 by
1343
1343
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1344
1344
  0.9.28 (ruby-2.7.2).
1345
1345
  </div>
@@ -79,7 +79,7 @@
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
81
  <dd>lib/battlesnake.rb<span class="defines">,<br />
82
- lib/battlesnake/snake.rb,<br /> lib/battlesnake/version.rb,<br /> lib/battlesnake/location.rb</span>
82
+ lib/battlesnake/board.rb,<br /> lib/battlesnake/snake.rb,<br /> lib/battlesnake/version.rb,<br /> lib/battlesnake/location.rb</span>
83
83
  </dd>
84
84
  </dl>
85
85
 
@@ -102,7 +102,7 @@
102
102
 
103
103
 
104
104
 
105
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span>, <span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span>, <span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>
105
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Battlesnake/Board.html" title="Battlesnake::Board (class)">Board</a></span>, <span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span>, <span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span>, <span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>
106
106
 
107
107
 
108
108
  </p>
@@ -145,7 +145,7 @@
145
145
  </div>
146
146
 
147
147
  <div id="footer">
148
- Generated on Fri Nov 4 14:55:40 2022 by
148
+ Generated on Fri Nov 4 19:07:49 2022 by
149
149
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
150
150
  0.9.28 (ruby-2.7.2).
151
151
  </div>
data/docs/_index.html CHANGED
@@ -85,6 +85,13 @@
85
85
 
86
86
  </li>
87
87
 
88
+ <li>
89
+ <span class='object_link'><a href="Battlesnake/Board.html" title="Battlesnake::Board (class)">Board</a></span>
90
+
91
+ <small>(Battlesnake)</small>
92
+
93
+ </li>
94
+
88
95
  </ul>
89
96
  </ul>
90
97
 
@@ -142,7 +149,7 @@
142
149
  </div>
143
150
 
144
151
  <div id="footer">
145
- Generated on Fri Nov 4 14:55:40 2022 by
152
+ Generated on Fri Nov 4 19:07:49 2022 by
146
153
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
147
154
  0.9.28 (ruby-2.7.2).
148
155
  </div>
data/docs/class_list.html CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  <ul id="full_list" class="class">
45
45
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
46
- <li id='object_Battlesnake' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Battlesnake::Error' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span> &lt; StandardError<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Location' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Snake' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li></ul></li>
46
+ <li id='object_Battlesnake' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Battlesnake::Board' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Board.html" title="Battlesnake::Board (class)">Board</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Error' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span> &lt; StandardError<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Location' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Snake' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li></ul></li>
47
47
 
48
48
  </ul>
49
49
  </div>
@@ -83,7 +83,7 @@
83
83
 
84
84
  <h2 id="label-Usage">Usage</h2>
85
85
 
86
- <p>Examples coming soon. For now, view our <a href="https://raw.githubusercontent.com/bellmyer/battlesnake/master/doc/_index.html">documentation</a>.</p>
86
+ <p>Examples coming soon. For now, view our <a href="https://bellmyer.github.io/battlesnake/">documentation</a>.</p>
87
87
 
88
88
  <h2 id="label-Development">Development</h2>
89
89
 
@@ -97,7 +97,7 @@
97
97
  </div></div>
98
98
 
99
99
  <div id="footer">
100
- Generated on Fri Nov 4 14:55:40 2022 by
100
+ Generated on Fri Nov 4 19:07:49 2022 by
101
101
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
102
102
  0.9.28 (ruby-2.7.2).
103
103
  </div>
data/docs/index.html CHANGED
@@ -83,7 +83,7 @@
83
83
 
84
84
  <h2 id="label-Usage">Usage</h2>
85
85
 
86
- <p>Examples coming soon. For now, view our <a href="https://raw.githubusercontent.com/bellmyer/battlesnake/master/doc/_index.html">documentation</a>.</p>
86
+ <p>Examples coming soon. For now, view our <a href="https://bellmyer.github.io/battlesnake/">documentation</a>.</p>
87
87
 
88
88
  <h2 id="label-Development">Development</h2>
89
89
 
@@ -97,7 +97,7 @@
97
97
  </div></div>
98
98
 
99
99
  <div id="footer">
100
- Generated on Fri Nov 4 14:55:40 2022 by
100
+ Generated on Fri Nov 4 19:07:49 2022 by
101
101
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
102
102
  0.9.28 (ruby-2.7.2).
103
103
  </div>
@@ -61,6 +61,14 @@
61
61
 
62
62
 
63
63
  <li class="odd ">
64
+ <div class="item">
65
+ <span class='object_link'><a href="Battlesnake/Board.html#as_json-instance_method" title="Battlesnake::Board#as_json (method)">#as_json</a></span>
66
+ <small>Battlesnake::Board</small>
67
+ </div>
68
+ </li>
69
+
70
+
71
+ <li class="even ">
64
72
  <div class="item">
65
73
  <span class='object_link'><a href="Battlesnake/Snake.html#body-instance_method" title="Battlesnake::Snake#body (method)">#body</a></span>
66
74
  <small>Battlesnake::Snake</small>
@@ -68,7 +76,7 @@
68
76
  </li>
69
77
 
70
78
 
71
- <li class="even ">
79
+ <li class="odd ">
72
80
  <div class="item">
73
81
  <span class='object_link'><a href="Battlesnake/Location.html#coords-instance_method" title="Battlesnake::Location#coords (method)">#coords</a></span>
74
82
  <small>Battlesnake::Location</small>
@@ -76,7 +84,7 @@
76
84
  </li>
77
85
 
78
86
 
79
- <li class="odd ">
87
+ <li class="even ">
80
88
  <div class="item">
81
89
  <span class='object_link'><a href="Battlesnake/Snake.html#customizations-instance_method" title="Battlesnake::Snake#customizations (method)">#customizations</a></span>
82
90
  <small>Battlesnake::Snake</small>
@@ -84,7 +92,7 @@
84
92
  </li>
85
93
 
86
94
 
87
- <li class="even ">
95
+ <li class="odd ">
88
96
  <div class="item">
89
97
  <span class='object_link'><a href="Battlesnake/Snake.html#direction-instance_method" title="Battlesnake::Snake#direction (method)">#direction</a></span>
90
98
  <small>Battlesnake::Snake</small>
@@ -92,7 +100,7 @@
92
100
  </li>
93
101
 
94
102
 
95
- <li class="odd ">
103
+ <li class="even ">
96
104
  <div class="item">
97
105
  <span class='object_link'><a href="Battlesnake/Location.html#direction-instance_method" title="Battlesnake::Location#direction (method)">#direction</a></span>
98
106
  <small>Battlesnake::Location</small>
@@ -100,7 +108,7 @@
100
108
  </li>
101
109
 
102
110
 
103
- <li class="even ">
111
+ <li class="odd ">
104
112
  <div class="item">
105
113
  <span class='object_link'><a href="Battlesnake/Location.html#distance-instance_method" title="Battlesnake::Location#distance (method)">#distance</a></span>
106
114
  <small>Battlesnake::Location</small>
@@ -108,7 +116,23 @@
108
116
  </li>
109
117
 
110
118
 
119
+ <li class="even ">
120
+ <div class="item">
121
+ <span class='object_link'><a href="Battlesnake/Board.html#food-instance_method" title="Battlesnake::Board#food (method)">#food</a></span>
122
+ <small>Battlesnake::Board</small>
123
+ </div>
124
+ </li>
125
+
126
+
111
127
  <li class="odd ">
128
+ <div class="item">
129
+ <span class='object_link'><a href="Battlesnake/Board.html#hazards-instance_method" title="Battlesnake::Board#hazards (method)">#hazards</a></span>
130
+ <small>Battlesnake::Board</small>
131
+ </div>
132
+ </li>
133
+
134
+
135
+ <li class="even ">
112
136
  <div class="item">
113
137
  <span class='object_link'><a href="Battlesnake/Snake.html#head-instance_method" title="Battlesnake::Snake#head (method)">#head</a></span>
114
138
  <small>Battlesnake::Snake</small>
@@ -116,7 +140,7 @@
116
140
  </li>
117
141
 
118
142
 
119
- <li class="even ">
143
+ <li class="odd ">
120
144
  <div class="item">
121
145
  <span class='object_link'><a href="Battlesnake/Snake.html#health-instance_method" title="Battlesnake::Snake#health (method)">#health</a></span>
122
146
  <small>Battlesnake::Snake</small>
@@ -124,6 +148,14 @@
124
148
  </li>
125
149
 
126
150
 
151
+ <li class="even ">
152
+ <div class="item">
153
+ <span class='object_link'><a href="Battlesnake/Board.html#height-instance_method" title="Battlesnake::Board#height (method)">#height</a></span>
154
+ <small>Battlesnake::Board</small>
155
+ </div>
156
+ </li>
157
+
158
+
127
159
  <li class="odd ">
128
160
  <div class="item">
129
161
  <span class='object_link'><a href="Battlesnake/Snake.html#id-instance_method" title="Battlesnake::Snake#id (method)">#id</a></span>
@@ -141,6 +173,14 @@
141
173
 
142
174
 
143
175
  <li class="odd ">
176
+ <div class="item">
177
+ <span class='object_link'><a href="Battlesnake/Board.html#initialize-instance_method" title="Battlesnake::Board#initialize (method)">#initialize</a></span>
178
+ <small>Battlesnake::Board</small>
179
+ </div>
180
+ </li>
181
+
182
+
183
+ <li class="even ">
144
184
  <div class="item">
145
185
  <span class='object_link'><a href="Battlesnake/Snake.html#initialize-instance_method" title="Battlesnake::Snake#initialize (method)">#initialize</a></span>
146
186
  <small>Battlesnake::Snake</small>
@@ -148,7 +188,7 @@
148
188
  </li>
149
189
 
150
190
 
151
- <li class="even ">
191
+ <li class="odd ">
152
192
  <div class="item">
153
193
  <span class='object_link'><a href="Battlesnake/Snake.html#latency-instance_method" title="Battlesnake::Snake#latency (method)">#latency</a></span>
154
194
  <small>Battlesnake::Snake</small>
@@ -156,7 +196,7 @@
156
196
  </li>
157
197
 
158
198
 
159
- <li class="odd ">
199
+ <li class="even ">
160
200
  <div class="item">
161
201
  <span class='object_link'><a href="Battlesnake/Snake.html#length-instance_method" title="Battlesnake::Snake#length (method)">#length</a></span>
162
202
  <small>Battlesnake::Snake</small>
@@ -164,7 +204,7 @@
164
204
  </li>
165
205
 
166
206
 
167
- <li class="even ">
207
+ <li class="odd ">
168
208
  <div class="item">
169
209
  <span class='object_link'><a href="Battlesnake/Location.html#move-instance_method" title="Battlesnake::Location#move (method)">#move</a></span>
170
210
  <small>Battlesnake::Location</small>
@@ -172,7 +212,7 @@
172
212
  </li>
173
213
 
174
214
 
175
- <li class="odd ">
215
+ <li class="even ">
176
216
  <div class="item">
177
217
  <span class='object_link'><a href="Battlesnake/Snake.html#name-instance_method" title="Battlesnake::Snake#name (method)">#name</a></span>
178
218
  <small>Battlesnake::Snake</small>
@@ -180,7 +220,7 @@
180
220
  </li>
181
221
 
182
222
 
183
- <li class="even ">
223
+ <li class="odd ">
184
224
  <div class="item">
185
225
  <span class='object_link'><a href="Battlesnake/Snake.html#shout-instance_method" title="Battlesnake::Snake#shout (method)">#shout</a></span>
186
226
  <small>Battlesnake::Snake</small>
@@ -188,6 +228,14 @@
188
228
  </li>
189
229
 
190
230
 
231
+ <li class="even ">
232
+ <div class="item">
233
+ <span class='object_link'><a href="Battlesnake/Board.html#snakes-instance_method" title="Battlesnake::Board#snakes (method)">#snakes</a></span>
234
+ <small>Battlesnake::Board</small>
235
+ </div>
236
+ </li>
237
+
238
+
191
239
  <li class="odd ">
192
240
  <div class="item">
193
241
  <span class='object_link'><a href="Battlesnake/Snake.html#squad-instance_method" title="Battlesnake::Snake#squad (method)">#squad</a></span>
@@ -197,6 +245,14 @@
197
245
 
198
246
 
199
247
  <li class="even ">
248
+ <div class="item">
249
+ <span class='object_link'><a href="Battlesnake/Board.html#width-instance_method" title="Battlesnake::Board#width (method)">#width</a></span>
250
+ <small>Battlesnake::Board</small>
251
+ </div>
252
+ </li>
253
+
254
+
255
+ <li class="odd ">
200
256
  <div class="item">
201
257
  <span class='object_link'><a href="Battlesnake/Location.html#x-instance_method" title="Battlesnake::Location#x (method)">#x</a></span>
202
258
  <small>Battlesnake::Location</small>
@@ -204,7 +260,7 @@
204
260
  </li>
205
261
 
206
262
 
207
- <li class="odd ">
263
+ <li class="even ">
208
264
  <div class="item">
209
265
  <span class='object_link'><a href="Battlesnake/Location.html#y-instance_method" title="Battlesnake::Location#y (method)">#y</a></span>
210
266
  <small>Battlesnake::Location</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Fri Nov 4 14:55:40 2022 by
103
+ Generated on Fri Nov 4 19:07:49 2022 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.28 (ruby-2.7.2).
106
106
  </div>
@@ -0,0 +1,43 @@
1
+ require 'json'
2
+
3
+ module Battlesnake
4
+ ##
5
+ # Represents a single iteration (turn) of a Battlesnake board during gameplay.
6
+ class Board
7
+ # @return [Hash] board as a data structure usable by other objects.
8
+ attr_reader :as_json
9
+
10
+ # @return [Integer] height of the board
11
+ attr_reader :height
12
+
13
+ # @return [Integer] width of the board
14
+ attr_reader :width
15
+
16
+ # @return [Array<Snake>] list of snake objects
17
+ attr_reader :snakes
18
+
19
+ # @return [Array<Location>] list of food location objects
20
+ attr_reader :food
21
+
22
+ # @return [Array<Location>] list of hazard location objects
23
+ attr_reader :hazards
24
+
25
+ ##
26
+ # Returns a new instance of Board.
27
+ #
28
+ # @param json_or_hash [String,Hash] can be a hash of attributes, or a JSON string which
29
+ # represents such a structure.
30
+ #
31
+ # @return [Board]
32
+ def initialize(json_or_hash)
33
+ data = json_or_hash.is_a?(String) ? JSON.parse(json_or_hash) : json_or_hash
34
+
35
+ @as_json = data
36
+ @height = data['height']
37
+ @width = data['width']
38
+ @snakes = data['snakes'].map{ |attrs| Snake.new(attrs) }
39
+ @food = data['food'].map{ |attrs| Location.new(attrs) }
40
+ @hazards = data['hazards'].map{ |attrs| Location.new(attrs) }
41
+ end
42
+ end
43
+ end
@@ -1,4 +1,4 @@
1
1
  module Battlesnake
2
2
  # The current version of the driver.
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
data/lib/battlesnake.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "battlesnake/version"
2
+ require 'battlesnake/board'
2
3
  require 'battlesnake/location'
3
4
  require 'battlesnake/snake'
4
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: battlesnake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Bellmyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
11
+ date: 2022-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -100,6 +100,7 @@ files:
100
100
  - bin/console
101
101
  - bin/setup
102
102
  - docs/Battlesnake.html
103
+ - docs/Battlesnake/Board.html
103
104
  - docs/Battlesnake/Error.html
104
105
  - docs/Battlesnake/Location.html
105
106
  - docs/Battlesnake/Snake.html
@@ -118,6 +119,7 @@ files:
118
119
  - docs/method_list.html
119
120
  - docs/top-level-namespace.html
120
121
  - lib/battlesnake.rb
122
+ - lib/battlesnake/board.rb
121
123
  - lib/battlesnake/location.rb
122
124
  - lib/battlesnake/snake.rb
123
125
  - lib/battlesnake/version.rb