Class: HMap::HMapHeader Abstract

Inherits:
HMapStructure show all
Defined in:
lib/cocoapods-hmap/hmap_struct.rb

Overview

This class is abstract.

HMapHeader structure.

Constant Summary collapse

FORMAT =
'L=1S=2L4'
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.

24

Constants inherited from HMapStructure

HMap::HMapStructure::SWAPPED

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HMapStructure

bytesize, format, new_from_bin, swapped?

Constructor Details

#initialize(magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length) ⇒ HMapHeader

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 a new instance of HMapHeader.



80
81
82
83
84
85
86
87
88
89
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 80

def initialize(magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length)
  @magic = magic
  @version = version
  @reserved = reserved
  @strings_offset = strings_offset
  @num_entries = num_entries
  @num_buckets = num_buckets
  @max_value_length = max_value_length
  super()
end

Instance Attribute Details

#magicHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def magic
  @magic
end

#max_value_lengthHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def max_value_length
  @max_value_length
end

#num_bucketsHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def num_buckets
  @num_buckets
end

#num_entriesHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def num_entries
  @num_entries
end

#reservedHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def reserved
  @reserved
end

#strings_offsetHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def strings_offset
  @strings_offset
end

#versionHMap::HMapView? (readonly)

Returns the raw view associated with the load command, or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command, or nil if the HMapHeader was created via create.



72
73
74
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 72

def version
  @version
end

Instance Method Details

#descriptionObject



97
98
99
100
101
102
103
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 97

def description
  "    Hash bucket count: \#{@num_buckets}\n    String table entry count: \#{@num_entries}\n    Max value length: \#{@max_value_length}\n  DESC\nend\n"

#serializeString

Returns the serialized fields of the mafile.

Returns:

  • (String)

    the serialized fields of the mafile



92
93
94
95
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 92

def serialize
  format = Utils.specialize_format(FORMAT, SWAPPED)
  [magic, version, reserved, strings_offset, num_entries, num_buckets, max_value_length].pack(format)
end

#to_hObject



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 105

def to_h
  {
    'magic' => magic,
    'version' => version,
    'reserved' => reserved,
    'strings_offset' => strings_offset,
    'num_entries' => num_entries,
    'num_buckets' => num_buckets,
    'max_value_length' => max_value_length
  }.merge super
end