Class: Sevgi::Graphics::Mixtures::Identify::Identifiers

Inherits:
Object
  • Object
show all
Defined in:
lib/sevgi/graphics/mixtures/identify.rb

Overview

Index of element ids under a subtree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ void

Builds an id index for an element subtree.

Parameters:



22
23
24
25
26
27
28
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 22

def initialize(element)
  @element = element
  @namespace = {}
  @collision = {}

  build
end

Instance Attribute Details

#collisionHash<String, Array<Sevgi::Graphics::Element>> (readonly)

Returns duplicate id groups.

Returns:



17
18
19
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 17

def collision
  @collision
end

#elementSevgi::Graphics::Element (readonly)

Returns indexed root element.

Returns:



11
12
13
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 11

def element
  @element
end

#namespaceHash<String, Sevgi::Graphics::Element> (readonly)

Returns id namespace.

Returns:



14
15
16
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 14

def namespace
  @namespace
end

Instance Method Details

#[](id) ⇒ Sevgi::Graphics::Element?

Returns the element registered for an id.

Parameters:

  • id (String)

    SVG id

Returns:



40
41
42
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 40

def [](*)
  @namespace[*]
end

#conflict?Boolean

Reports whether duplicate ids were found.

Returns:

  • (Boolean)


32
33
34
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 32

def conflict?
  !@collision.empty?
end