Class: Diffed::DiffHeaderLine

Inherits:
Object
  • Object
show all
Defined in:
lib/diffed.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ DiffHeaderLine

Returns a new instance of DiffHeaderLine.



143
144
145
146
147
148
149
150
# File 'lib/diffed.rb', line 143

def initialize(line)
  if line =~ /^@@ -(\d+),(\d+) \+(\d+),(\d+) @@/
    @text = line
    @line_nums = {left: {from: $1.to_i, to: $2.to_i}, right: {from: $1.to_i, to: $2.to_i}}
  else
    raise "Unparseable header line: #{line}"
  end
end

Instance Attribute Details

#line_numsObject (readonly)

Returns the value of attribute line_nums.



141
142
143
# File 'lib/diffed.rb', line 141

def line_nums
  @line_nums
end

#textObject (readonly)

Returns the value of attribute text.



141
142
143
# File 'lib/diffed.rb', line 141

def text
  @text
end

Class Method Details

.is_header?(line) ⇒ Boolean

Returns:

  • (Boolean)


152
153
154
# File 'lib/diffed.rb', line 152

def self.is_header?(line)
  line.start_with? "@@ "
end