Class: HashDeepDiff::Reports::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_deep_diff/reports/base.rb

Overview

Abstract Class

Direct Known Subclasses

Diff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delta:) ⇒ Base (private)

Returns a new instance of Base.

Parameters:

  • delta (Delta)

    diff to report



25
26
27
28
29
# File 'lib/hash_deep_diff/reports/base.rb', line 25

def initialize(delta:)
  @change_key = delta.change_key.to_ary
  @old_val = delta.left
  @new_val = delta.right
end

Instance Attribute Details

#change_keyObject (readonly, private)

Returns the value of attribute change_key.



22
23
24
# File 'lib/hash_deep_diff/reports/base.rb', line 22

def change_key
  @change_key
end

#new_valObject (readonly, private)

Returns the value of attribute new_val.



22
23
24
# File 'lib/hash_deep_diff/reports/base.rb', line 22

def new_val
  @new_val
end

#old_valObject (readonly, private)

Returns the value of attribute old_val.



22
23
24
# File 'lib/hash_deep_diff/reports/base.rb', line 22

def old_val
  @old_val
end

Instance Method Details

#originalObject (private)

old value



32
33
34
# File 'lib/hash_deep_diff/reports/base.rb', line 32

def original
  raise AbstractMethodError
end

#replacementObject (private)

new value



37
38
39
# File 'lib/hash_deep_diff/reports/base.rb', line 37

def replacement
  raise AbstractMethodError
end

#to_sString

see #to_str

Returns:

  • (String)


10
11
12
# File 'lib/hash_deep_diff/reports/base.rb', line 10

def to_s
  to_str
end

#to_strString

A report on additions and deletions

Returns:

  • (String)


16
17
18
# File 'lib/hash_deep_diff/reports/base.rb', line 16

def to_str
  original + replacement
end