Class: PVN::Diff::Paths

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Logue::Loggable
Defined in:
lib/pvn/diff/paths.rb

Overview

represents the paths from one revision through another.

Direct Known Subclasses

LogPaths, StatusPaths

Instance Method Summary collapse

Constructor Details

#initialize(revision, paths) ⇒ Paths

takes paths of the form “.”, “foo.rb”, etc.



13
14
15
16
17
18
19
20
# File 'lib/pvn/diff/paths.rb', line 13

def initialize revision, paths
  @revision = revision
  @elements = SortedSet.new
  
  paths.each do |path|
    add_for_path path
  end
end

Instance Method Details

#[](idx) ⇒ Object



26
27
28
# File 'lib/pvn/diff/paths.rb', line 26

def [] idx
  @elements.to_a[idx]
end

#add_for_path(path) ⇒ Object



22
23
24
# File 'lib/pvn/diff/paths.rb', line 22

def add_for_path path
  raise "implement this"
end

#each(&blk) ⇒ Object



41
42
43
# File 'lib/pvn/diff/paths.rb', line 41

def each(&blk)
  @elements.each(&blk)
end

#sizeObject



30
31
32
# File 'lib/pvn/diff/paths.rb', line 30

def size
  @elements.size
end

#to_mapObject

returns a map from names to logpaths



35
36
37
38
39
# File 'lib/pvn/diff/paths.rb', line 35

def to_map
  names_to_paths = Hash.new
  @elements.each { |path| names_to_paths[path.name] = path }
  names_to_paths
end