class HMap::HMapSaver
Attributes
buckets[R]
headers[R]
string_table[R]
Public Class Methods
new()
click to toggle source
# File lib/cocoapods-hmap/hmap_save.rb, line 7 def initialize @string_table = "\0" @buckets = [] @headers = {} end
Public Instance Methods
add_to_buckets(*buckets)
click to toggle source
# File lib/cocoapods-hmap/hmap_save.rb, line 35 def add_to_buckets(*buckets) values = buckets.map { |key| add_to_headers(key) } bucket = HMapBucket.new(*values) bucket.uuid = Utils.string_downcase_hash(buckets.first) @buckets << bucket end
add_to_headers(key)
click to toggle source
# File lib/cocoapods-hmap/hmap_save.rb, line 27 def add_to_headers(key) if headers[key].nil? headers[key] = string_table.length add_to_string_table(key) end headers[key] end
add_to_string_table(str)
click to toggle source
# File lib/cocoapods-hmap/hmap_save.rb, line 23 def add_to_string_table(str) @string_table += "#{Utils.safe_encode(str, 'ASCII-8BIT')}\0" end
header_to_hash(keys, headers, index, buckets)
click to toggle source
# File lib/cocoapods-hmap/hmap_save.rb, line 13 def header_to_hash(keys, headers, index, buckets) index = index.length keys.inject('') do |sum, bucket| buckte = HMapBucketStr.new(*bucket) string_t = buckte.bucket_to_string(headers, index + sum.length) buckets.push(buckte) sum + string_t end end
write_to(path)
click to toggle source
# File lib/cocoapods-hmap/hmap_save.rb, line 42 def write_to(path) MapFile.new(@string_table, @buckets).write(path) end