Class: HMap::HMapHeader Abstract

Inherits:
HMapStructure show all
Defined in:
lib/cocoapods-hmap-prebuilt/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.



77
78
79
80
81
82
83
84
85
86
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 77

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)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def magic
  @magic
end

#max_value_lengthHMap::HMapView? (readonly)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def max_value_length
  @max_value_length
end

#num_bucketsHMap::HMapView? (readonly)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def num_buckets
  @num_buckets
end

#num_entriesHMap::HMapView? (readonly)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def num_entries
  @num_entries
end

#reservedHMap::HMapView? (readonly)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def reserved
  @reserved
end

#strings_offsetHMap::HMapView? (readonly)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def strings_offset
  @strings_offset
end

#versionHMap::HMapView? (readonly)

or nil if the HMapHeader was created via create.

Returns:

  • (HMap::HMapView, nil)

    the raw view associated with the load command,



69
70
71
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 69

def version
  @version
end

Instance Method Details

#descriptionObject



94
95
96
97
98
99
100
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 94

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



89
90
91
92
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 89

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



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 102

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