Class: Ea::Validation::XmiParity::Counts

Inherits:
Struct
  • Object
show all
Defined in:
lib/ea/validation/xmi_parity.rb

Overview

Per-element counts for one XMI document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCounts

Returns a new instance of Counts.



33
34
35
36
# File 'lib/ea/validation/xmi_parity.rb', line 33

def initialize(*)
  super
  self.by_type ||= {}
end

Instance Attribute Details

#by_typeObject

Returns the value of attribute by_type

Returns:

  • (Object)

    the current value of by_type



32
33
34
# File 'lib/ea/validation/xmi_parity.rb', line 32

def by_type
  @by_type
end

#totalObject

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



32
33
34
# File 'lib/ea/validation/xmi_parity.rb', line 32

def total
  @total
end

Instance Method Details

#delta(other) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/ea/validation/xmi_parity.rb', line 38

def delta(other)
  result = { total: total - other.total }
  ELEMENT_TYPES.each do |t|
    result[t] = (by_type[t] || 0) - (other.by_type[t] || 0)
  end
  result
end