Class: HMap::MapFile

Inherits:
Object
  • Object
show all
Defined in:
lib/hmap/hmap/mapfile.rb

Overview

hmap file writer

Instance Method Summary collapse

Constructor Details

#initialize(strings, buckets, entries) ⇒ MapFile

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 MapFile.



7
8
9
# File 'lib/hmap/hmap/mapfile.rb', line 7

def initialize(strings, buckets, entries)
  @map_data = HMapData.new(strings, buckets, entries)
end

Instance Method Details

#serializeString

Returns the serialized fields of the mafile.

Returns:

  • (String)

    the serialized fields of the mafile



12
13
14
# File 'lib/hmap/hmap/mapfile.rb', line 12

def serialize
  @map_data.serialize
end

#write(filepath, contents = nil) ⇒ void

This method returns an undefined value.

Write all mafile data to the given filename.

Parameters:

  • filename (String)

    the file to write to



19
20
21
22
# File 'lib/hmap/hmap/mapfile.rb', line 19

def write(filepath, contents = nil)
  contents = serialize if contents.nil?
  Utils.update_changed_file(filepath, contents)
end