Parent

Methods

Diff::LCS::HTMLDiff

Attributes

options[R]

Public Class Methods

new(left, right, options = nil) click to toggle source
# File lib/diff/lcs/htmldiff.rb, line 88
def initialize(left, right, options = nil)
  @left     = left
  @right    = right
  @options  = options

  @options = DEFAULT_OPTIONS.dup if @options.nil?
end

Public Instance Methods

run() click to toggle source
# File lib/diff/lcs/htmldiff.rb, line 110
def run
  verify_options

  if @options[:expand_tabs] > 0 && self.class.can_expand_tabs
    formatter = Text::Format.new
    formatter.tabstop = @options[:expand_tabs]

    @left = left.map { |line| formatter.expand(line.chomp) }
    @right = right.map { |line| formatter.expand(line.chomp) }
  end

  @left.map! { |line| CGI.escapeHTML(line.chomp) }
  @right.map! { |line| CGI.escapeHTML(line.chomp) }

  @options[:output] << <html>  <head>    <title>#{@options[:title]}</title>    <style type="text/css">    #{@options[:css]}    </style>  </head>  <body>    <h1>#{@options[:title]}</h1>    <p>Legend: <span class="only_a">Only in Old</span>&nbsp;    <span class="only_b">Only in New</span></p>    <div class="diff">

  callbacks = Callbacks.new(@options[:output])
  Diff::LCS.traverse_sequences(@left, @right, callbacks)

  @options[:output] <<     </div>  </body></html>
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.