Class: Emfsvg::Compat::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/emfsvg/compat.rb

Overview

Per-fixture comparison result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emfsvg_bytesObject

Returns the value of attribute emfsvg_bytes

Returns:

  • (Object)

    the current value of emfsvg_bytes



77
78
79
# File 'lib/emfsvg/compat.rb', line 77

def emfsvg_bytes
  @emfsvg_bytes
end

#emfsvg_elementsObject

Returns the value of attribute emfsvg_elements

Returns:

  • (Object)

    the current value of emfsvg_elements



77
78
79
# File 'lib/emfsvg/compat.rb', line 77

def emfsvg_elements
  @emfsvg_elements
end

#fixtureObject

Returns the value of attribute fixture

Returns:

  • (Object)

    the current value of fixture



77
78
79
# File 'lib/emfsvg/compat.rb', line 77

def fixture
  @fixture
end

#ref_bytesObject

Returns the value of attribute ref_bytes

Returns:

  • (Object)

    the current value of ref_bytes



77
78
79
# File 'lib/emfsvg/compat.rb', line 77

def ref_bytes
  @ref_bytes
end

#ref_elementsObject

Returns the value of attribute ref_elements

Returns:

  • (Object)

    the current value of ref_elements



77
78
79
# File 'lib/emfsvg/compat.rb', line 77

def ref_elements
  @ref_elements
end

Instance Method Details

#byte_ratioObject



79
80
81
# File 'lib/emfsvg/compat.rb', line 79

def byte_ratio
  ref_bytes.zero? ? 0.0 : (emfsvg_bytes.to_f / ref_bytes * 100).round(1)
end

#element_overlapObject



83
84
85
86
87
88
89
# File 'lib/emfsvg/compat.rb', line 83

def element_overlap
  return 0.0 if emfsvg_elements.empty?

  shared = emfsvg_elements.keys & ref_elements.keys
  shared.sum { |k| [emfsvg_elements[k], ref_elements[k]].min }.to_f /
    emfsvg_elements.values.sum
end

#to_sObject



91
92
93
94
# File 'lib/emfsvg/compat.rb', line 91

def to_s
  format("%-40s ref=%8d out=%7d (%5.1f%%) elements_overlap=%.1f",
         fixture, ref_bytes, emfsvg_bytes, byte_ratio, element_overlap * 100)
end