Class: Diff::LCS::HTMLDiff

### Home Classes Methods

### In Files

- lib/diff/lcs/htmldiff.rb

### Parent

Object

### Namespace

- CLASS Diff::LCS::HTMLDiff::Callbacks

### Methods

- ::new
- #run

### Files

- Manifest.txt
- README.rdoc
- COPYING.txt
- artistic.txt

### Class/Module Index

Quicksearch

- Diff
- Diff::LCS
- Diff::LCS::BalancedCallbacks
- Diff::LCS::Block
- Diff::LCS::Change
- Diff::LCS::ContextChange
- Diff::LCS::ContextDiffCallbacks
- Diff::LCS::DefaultCallbacks
- Diff::LCS::DiffCallbacks
- Diff::LCS::HTMLDiff
- Diff::LCS::HTMLDiff::Callbacks
- Diff::LCS::Hunk
- Diff::LCS::Ldiff
- Diff::LCS::SDiffCallbacks
- Diff::LCS::SequenceCallbacks
- Array
- String

No matching classes.

# Diff::LCS::HTMLDiff

### Constants

DEFAULT_CSS
DEFAULT_OPTIONS

### 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.