Sha256: 128edf0451d39354d56a4589c631bc1af59f84cb1f40a4fe81d83886fa391ee5
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
# # Represent a single line of the diff. # class PrettyDiff::Line #:nodoc: attr_reader :diff, :input def initialize(diff, input) @diff = diff @input = input end # Generate HTML presentation for a Line. Return a string. def to_html generator.generate end # Prepare Line contents for injection into HTML structure. # Currently used for replacing Tab symbols with spaces. # Return a string. def format input.gsub("\t", ' ') end # Unified Diff sometimes emit a special line at the end of the file # that we should not display in the output. # Return true or false. def ignore? input =~ /\\ No newline at end of file/ end # Return status of the Line. Can be :added, :deleted or :not_modified. def status case input when /^\+/ :added when /^\-/ :deleted else :not_modified end end def added? status == :added end def deleted? status == :deleted end def not_modified? status == :not_modified end private def generator @_generator ||= PrettyDiff::LineGenerator.new(self) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pretty_diff-0.8.1 | lib/pretty_diff/line.rb |
pretty_diff-0.8.0 | lib/pretty_diff/line.rb |
pretty_diff-0.7.0 | lib/pretty_diff/line.rb |