Class: Ea::Svg::Parity::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/svg/parity/checker.rb

Overview

Compares an emitted SVG against one EA reference SVG across element counts, font-family, viewBox, and text overlap.

Defined Under Namespace

Classes: Diff, Report

Constant Summary collapse

ELEMENT_TYPES =
%i[rect path polygon text group].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ours:, reference:) ⇒ Checker

Returns a new instance of Checker.



15
16
17
18
# File 'lib/ea/svg/parity/checker.rb', line 15

def initialize(ours:, reference:)
  @ours = ours
  @reference = reference
end

Instance Attribute Details

#oursObject (readonly)

Returns the value of attribute ours.



13
14
15
# File 'lib/ea/svg/parity/checker.rb', line 13

def ours
  @ours
end

#referenceObject (readonly)

Returns the value of attribute reference.



13
14
15
# File 'lib/ea/svg/parity/checker.rb', line 13

def reference
  @reference
end

Instance Method Details

#reportObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ea/svg/parity/checker.rb', line 20

def report
  Report.new(
    rect: count_diff("rect"),
    path: count_diff("path"),
    polygon: count_diff("polygon"),
    text: count_diff("text"),
    group: top_level_group_diff,
    font_family: font_family_match,
    view_box: view_box_match,
    text_overlap: text_overlap_ratio
  )
end