Class: Darcs::Chunk::Hunk

Inherits:
Base
  • Object
show all
Defined in:
lib/darcs/patchwriter.rb

Overview

Chunk which makes a modification to a text file. If the file is binary, you will need to use Darcs::Chunk::Binary instead

FIXME: We should create aggregate chunks to do a lot of the foot work for diffing, what not. An AddFileWithData chunk, A DiffFile chunk, whatnot. Or maybe a different method will present itself?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, line, data) ⇒ Hunk

Creates a new hunk chunk for the specified file and line.



88
89
90
91
92
# File 'lib/darcs/patchwriter.rb', line 88

def initialize(path, line, data)
  @path = path
  @line = line
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



94
95
96
# File 'lib/darcs/patchwriter.rb', line 94

def data
  @data
end

#lineObject (readonly)

Returns the value of attribute line.



94
95
96
# File 'lib/darcs/patchwriter.rb', line 94

def line
  @line
end

#pathObject (readonly)

Returns the value of attribute path.



94
95
96
# File 'lib/darcs/patchwriter.rb', line 94

def path
  @path
end

Instance Method Details

#write(io, patch) ⇒ Object



96
97
98
# File 'lib/darcs/patchwriter.rb', line 96

def write(io, patch)
  io.write("hunk #{path} #{line}\n#{data}")
end