Class: HMap::HMapBucketStr Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-hmap-prebuilt/hmap_struct.rb

Overview

This class is abstract.

HMapBucketStr => HMapBucket.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, perfix, suffix) ⇒ HMapBucketStr

Returns a new instance of HMapBucketStr.



121
122
123
124
125
126
127
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 121

def initialize(key, perfix, suffix)
  @uuid = Utils.string_downcase_hash(key)
  @key = key
  @perfix = perfix
  @suffix = suffix
  @str_ins = {}
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



119
120
121
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 119

def key
  @key
end

#perfixObject (readonly)

Returns the value of attribute perfix.



119
120
121
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 119

def perfix
  @perfix
end

#suffixObject (readonly)

Returns the value of attribute suffix.



119
120
121
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 119

def suffix
  @suffix
end

#uuidObject (readonly)

Returns the value of attribute uuid.



119
120
121
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 119

def uuid
  @uuid
end

Instance Method Details

#bucketObject



141
142
143
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 141

def bucket
  HMapBucket.new(@str_ins[@key], @str_ins[@perfix], @str_ins[@suffix])
end

#bucket_to_string(headers, index) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 129

def bucket_to_string(headers, index)
  bucket = [key, perfix, suffix]
  bucket.inject('') do |sum, arg|
    if headers[arg].nil?
      headers[arg] = sum.length + index
      sum += "#{Utils.safe_encode(arg, 'ASCII-8BIT')}\0"
    end
    @str_ins[arg] = headers[arg]
    sum
  end
end

#descriptionObject



150
151
152
153
154
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 150

def description
  <<-DESC
    Key #{@key} -> Prefix #{@perfix}, Suffix #{@suffix}
  DESC
end

#serializeString

Returns the serialized fields of the mafile.

Returns:

  • (String)

    the serialized fields of the mafile



146
147
148
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 146

def serialize
  bucket.serialize
end

#to_hObject



156
157
158
159
160
161
162
# File 'lib/cocoapods-hmap-prebuilt/hmap_struct.rb', line 156

def to_h
  {
    'key' => { 'index' => str_ins[@key], 'key' => @key },
    'perfix' => { 'index' => str_ins[@perfix], 'perfix' => @perfix },
    'suffix' => { 'index' => str_ins[@suffix], 'suffix' => @suffix }
  }
end