Class: Dbsketch::Comparison::Diff

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(old_value, new_value) ⇒ Diff

Returns a new instance of Diff.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/dbsketch/comparison/diff.rb', line 9

def initialize old_value, new_value
	### Preconditions
	raise ArgumentError, "new_value is not different from old_value" unless new_value != old_value
	###
	@old_value = old_value
	@new_value = new_value
end

Instance Attribute Details

#new_valueObject (readonly)

Returns the value of attribute new_value.



17
18
19
# File 'lib/dbsketch/comparison/diff.rb', line 17

def new_value
  @new_value
end

#old_valueObject (readonly)

Returns the value of attribute old_value.



17
18
19
# File 'lib/dbsketch/comparison/diff.rb', line 17

def old_value
  @old_value
end

Instance Method Details

#addition?Boolean

Returns true if the diff represents the addition of a new value

Returns:

  • (Boolean)


30
31
32
# File 'lib/dbsketch/comparison/diff.rb', line 30

def addition?
	nil == @old_value and nil != @new_value
end

#change?Boolean

Returns true if the diff represents a change

Returns:

  • (Boolean)


25
26
27
# File 'lib/dbsketch/comparison/diff.rb', line 25

def change?
	nil != @old_value and nil != @new_value
end

#deletion?Boolean

Returns true if the diff represents the deletion of an old value

Returns:

  • (Boolean)


20
21
22
# File 'lib/dbsketch/comparison/diff.rb', line 20

def deletion?
	nil != @old_value and nil == @new_value
end