Class: Gorillib::DiffFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gorillib/diff.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DiffFormatter

Returns a new instance of DiffFormatter.


140
141
142
143
144
145
146
147
148
149
# File 'lib/gorillib/diff.rb', line 140

def initialize(options = {})
  @drawer = (options[:drawer] ||
             DiffDrawer.new(stream: options.delete(:stream),
                            left: options.delete(:left),
                            right: options.delete(:right),
                            indentation: options.delete(:indentation),
                            tab_width: options.delete(:tab_width)))

  @context_atoms = options[:context_atoms] || 0
end

Instance Method Details

#display_diff(this, other) ⇒ Object


151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/gorillib/diff.rb', line 151

def display_diff(this, other)
  setup
  if this.is_a?(Hash) && other.is_a?(Hash)
    display_diff_hash(this, other)
  elsif this.is_a?(Array) && other.is_a?(Array)
    display_diff_arr(this, other)
  elsif ((this.is_a?(Hash) != other.is_a?(Hash)) ||
         (this.is_a?(Array) != other.is_a?(Array)))
    display_diff_hetero(this, other)
  else
    display_diff_atom(this, other)
  end
end