Class: InspectorHashes::Inspector
- Inherits:
-
Object
- Object
- InspectorHashes::Inspector
- Defined in:
- lib/inspector_hashes/inspector.rb
Overview
‘InspectorHashes.diff(a, b)` will return:
-
nil (if equal)
-
if given simple objects, a single difference object: “‘
{ where: '', a: a, b: b }
“‘
-
if a hash or an array: the array of differences.
Constant Summary collapse
- SEPARATOR =
' > '.freeze
- NO_KEY =
'<<<key not present>>>'.freeze
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#a_exists ⇒ Object
Returns the value of attribute a_exists.
-
#b ⇒ Object
Returns the value of attribute b.
-
#b_exists ⇒ Object
Returns the value of attribute b_exists.
-
#prefixes ⇒ Object
Returns the value of attribute prefixes.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(a:, b:, a_exists: true, b_exists: true, prefixes: []) ⇒ Inspector
constructor
A new instance of Inspector.
Constructor Details
#initialize(a:, b:, a_exists: true, b_exists: true, prefixes: []) ⇒ Inspector
Returns a new instance of Inspector.
16 17 18 19 20 21 22 |
# File 'lib/inspector_hashes/inspector.rb', line 16 def initialize(a:, b:, a_exists: true, b_exists: true, prefixes: []) self.a = a self.b = b self.a_exists = a_exists self.b_exists = b_exists self.prefixes = prefixes end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
11 12 13 |
# File 'lib/inspector_hashes/inspector.rb', line 11 def a @a end |
#a_exists ⇒ Object
Returns the value of attribute a_exists.
11 12 13 |
# File 'lib/inspector_hashes/inspector.rb', line 11 def a_exists @a_exists end |
#b ⇒ Object
Returns the value of attribute b.
11 12 13 |
# File 'lib/inspector_hashes/inspector.rb', line 11 def b @b end |
#b_exists ⇒ Object
Returns the value of attribute b_exists.
11 12 13 |
# File 'lib/inspector_hashes/inspector.rb', line 11 def b_exists @b_exists end |
#prefixes ⇒ Object
Returns the value of attribute prefixes.
11 12 13 |
# File 'lib/inspector_hashes/inspector.rb', line 11 def prefixes @prefixes end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 |
# File 'lib/inspector_hashes/inspector.rb', line 24 def call return nil if a_exists && b_exists && a == b prepare_diff end |