Sha256: d8dcf9f6250eca29ad52be31307fe9e61350c66bb9c8db70b609f9ec09db45d8
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
require 'formatters/diff_html' module Diffed class Line include DiffHtml attr_reader :type, :text, :left_line_num, :right_line_num, :no_newline def initialize(type, text, left_line_num, right_line_num) @type, @text, @left_line_num, @right_line_num, @no_newline = type, text, left_line_num, right_line_num, false end def left? @type == :left || @type == :both end def right? @type == :right || @type == :both end def no_newline= bool # mutability like this kind of sucks, but this one's a pain to avoid. @no_newline = bool end def as_html_row(use_inline_styles, highlight = false) format_code_line(use_inline_styles, highlight) end private def format_code_line(use_inline_styles, highlight) row = OutputRow.new(:code_line => self) if use_inline_styles format_styled_row code_line_color(highlight), '#000', row, :highlight => highlight, :border_color => border_color else format_classed_row type.to_s, row, :highlight => highlight end end def code_line_color(highlight) if highlight && type == :both '#FFFBCC' else colors = {left: '#FDD', right: '#DFD', both: nil} colors[type] end end def border_color border_colors = {left: '#F55', right: '#5F5', both: '#999'} border_colors[type] end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
diffed-0.0.16 | lib/models/line.rb |
diffed-0.0.15 | lib/models/line.rb |
diffed-0.0.14 | lib/models/line.rb |
diffed-0.0.13 | lib/models/line.rb |
diffed-0.0.12 | lib/models/line.rb |