Method: WCC::DiffItem#initialize
- Defined in:
- lib/wcc/diff.rb
#initialize(line) ⇒ DiffItem
Returns a new instance of DiffItem.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wcc/diff.rb', line 8 def initialize(line) # parse line if line.start_with?('+++') @status = :new @text = line.substring(3) elsif line.start_with?('---') @status = :old @text = line.substring(3) elsif line.start_with?('@@') @status = :range @text = line.substring(2) elsif line.start_with?('+') @status = :ins @text = line.substring(1) elsif line.start_with?('-') @status = :del @text = line.substring(1) else @status = :other @text = line.rstrip @text = ' ' if @text.empty? end @text.gsub!(/\n/, '') @hilite = nil end |