Class: HMap::HMapBucketStr Abstract

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



124
125
126
127
128
129
130
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 124

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.



122
123
124
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 122

def key
  @key
end

#perfixObject (readonly)

Returns the value of attribute perfix.



122
123
124
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 122

def perfix
  @perfix
end

#suffixObject (readonly)

Returns the value of attribute suffix.



122
123
124
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 122

def suffix
  @suffix
end

#uuidObject (readonly)

Returns the value of attribute uuid.



122
123
124
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 122

def uuid
  @uuid
end

Instance Method Details

#bucketObject



144
145
146
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 144

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

#bucket_to_string(headers, index) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 132

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



153
154
155
156
157
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 153

def description
  "    Key \#{@key} -> Prefix \#{@perfix}, Suffix \#{@suffix}\n  DESC\nend\n"

#serializeString

Returns the serialized fields of the mafile.

Returns:

  • (String)

    the serialized fields of the mafile



149
150
151
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 149

def serialize
  bucket.serialize
end

#to_hObject



159
160
161
162
163
164
165
# File 'lib/cocoapods-hmap/hmap_struct.rb', line 159

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