Class: PVN::Diff::Paths

Inherits:
Object
  • Object
show all
Includes:
Enumerable, 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.



10
11
12
13
14
15
16
17
# File 'lib/pvn/diff/paths.rb', line 10

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

Instance Method Details

#[](idx) ⇒ Object



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

def [] idx
  @elements[idx]
end

#add_for_path(path) ⇒ Object



19
20
21
# File 'lib/pvn/diff/paths.rb', line 19

def add_for_path path
  raise "implement this"
end

#each(&blk) ⇒ Object



38
39
40
# File 'lib/pvn/diff/paths.rb', line 38

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

#sizeObject



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

def size
  @elements.size
end

#to_mapObject

returns a map from names to logpaths



32
33
34
35
36
# File 'lib/pvn/diff/paths.rb', line 32

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