Sha256: c2b77e98656b7338126fb63fab827b60fe1e12c4b36caed148981831c3e42dbb

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

class PrettyDiff::LineGenerator
  
  attr_reader :line
  
  def initialize(line)
    @line = line
  end
  
  def generate
    if line.added?
      added_html(content)
    elsif line.deleted?
      deleted_html(content)
    else
      not_modified_html(content)
    end
  end
  
private

  def content
    @_content ||= line.format
  end
  
  def wrapper_html
    if line.diff.options[:wrap_lines]
      "<div> #{yield} </div>"
    else
      yield
    end
  end

  def added_html(text)
    wrapper_html { %Q[<span class="gi">#{text}</span>] }
  end

  def deleted_html(text)
    wrapper_html { %Q[<span class="gd">#{text}</span>] }
  end

  def not_modified_html(text)
    wrapper_html { %Q[#{text}] }
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pretty_diff-0.6.0 lib/pretty_diff/html_generators/line_generator.rb