Class: Amp::ManifestEntry

Inherits:
Hash show all
Defined in:
lib/amp/revlogs/manifest.rb

Instance Method Summary collapse

Methods inherited from Hash

#[], #get, #pick, with_keys

Constructor Details

#initialize(mapping = nil, flags = nil) ⇒ ManifestEntry

Initializes the dictionary. It can be empty, by initializing with no arguments, or with more data by assigning them.

It is a hash of Filename => node_id

Parameters:

  • mapping (Hash) (defaults to: nil)

    the initial settings of the dictionary

  • flags (Hash) (defaults to: nil)

    the flag settings of the dictionary



13
14
15
16
17
# File 'lib/amp/revlogs/manifest.rb', line 13

def initialize(mapping=nil, flags=nil)
  @source_hash = mapping || {}
  super(@source_hash || {})
  @flags = flags || {}
end

Instance Method Details

#cloneObject Also known as: dup

Clones the dictionary



37
38
39
# File 'lib/amp/revlogs/manifest.rb', line 37

def clone
  self.class.new @source_hash.dup, @flags.dup
end

#delete(*args) ⇒ Object



30
31
32
33
# File 'lib/amp/revlogs/manifest.rb', line 30

def delete(*args)
  super(*args)
  flags.delete(*args)
end

#filesObject



28
# File 'lib/amp/revlogs/manifest.rb', line 28

def files; keys; end

#flags(file = nil) ⇒ Object



24
25
26
# File 'lib/amp/revlogs/manifest.rb', line 24

def flags(file=nil)
  file ? @flags[file] : @flags
end

#inspectObject



19
20
21
22
# File 'lib/amp/revlogs/manifest.rb', line 19

def inspect
  "#<ManifestEntry " + @source_hash.inspect + "\n" +
  "                " + @flags.inspect + ">"
end

#mark_for_later(file, node) ⇒ Object

Mark a file to be checked later on

Parameters:

  • file (String)

    the file to be marked for later checking

  • []


49
50
51
52
# File 'lib/amp/revlogs/manifest.rb', line 49

def mark_for_later(file, node)
  self[file]  = nil # notice how we DIDN'T use `self.delete file`
  flags[file] = node.flags file
end