Class: HMap::HMapStructure Abstract
- Inherits:
-
Object
- Object
- HMap::HMapStructure
- Defined in:
- lib/cocoapods-hmap/hmap_struct.rb
Overview
A general purpose pseudo-structure.
Direct Known Subclasses
Constant Summary collapse
- FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The String#unpack format of the data structure.
''- SIZEOF =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The size of the data structure, in bytes.
0- SWAPPED =
true
Class Method Summary collapse
-
.bytesize ⇒ Integer
The size, in bytes, of the represented structure.
- .format ⇒ Object
-
.new_from_bin(swapped, bin) ⇒ HMap::HMapStructure
private
The resulting structure.
- .swapped? ⇒ Boolean
Instance Method Summary collapse
- #serialize ⇒ Object
-
#to_h ⇒ Hash
A hash representation of this HMapStructure.
Class Method Details
.bytesize ⇒ Integer
Returns the size, in bytes, of the represented structure.
30 31 32 |
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 30 def self.bytesize self::SIZEOF end |
.format ⇒ Object
34 35 36 |
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 34 def self.format self::FORMAT end |
.new_from_bin(swapped, bin) ⇒ HMap::HMapStructure
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the resulting structure.
46 47 48 49 |
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 46 def self.new_from_bin(swapped, bin) format = Utils.specialize_format(self::FORMAT, swapped) new(*bin.unpack(format)) end |
.swapped? ⇒ Boolean
38 39 40 |
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 38 def self.swapped? self::SWAPPED end |
Instance Method Details
#serialize ⇒ Object
51 52 53 |
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 51 def serialize [].pack(format) end |
#to_h ⇒ Hash
Returns a hash representation of this HMap::HMapStructure.
56 57 58 59 60 61 62 63 |
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 56 def to_h { 'structure' => { 'format' => self.class::FORMAT, 'bytesize' => self.class.bytesize } } end |