Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/classes.rb
Overview
Copyright © 2013 Howard Jeng
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Class Method Summary collapse
Instance Method Summary collapse
- #_dump(*_ignored) ⇒ Object
-
#initialize(bytes) ⇒ Table
constructor
A new instance of Table.
Constructor Details
#initialize(bytes) ⇒ Table
Returns a new instance of Table.
22 23 24 25 |
# File 'lib/classes.rb', line 22 def initialize(bytes) @dim, @x, @y, @z, items, *@data = bytes.unpack('L5 S*') raise 'Size mismatch loading Table from data' unless items == @data.length && @x * @y * @z == items end |
Class Method Details
._load(bytes) ⇒ Object
31 32 33 |
# File 'lib/classes.rb', line 31 def self._load(bytes) new(bytes) end |
Instance Method Details
#_dump(*_ignored) ⇒ Object
27 28 29 |
# File 'lib/classes.rb', line 27 def _dump(*_ignored) [@dim, @x, @y, @z, @x * @y * @z, *@data].pack('L5 S*') end |