Class: Archimate::Lint::DuplicateEntities

Inherits:
Object
  • Object
show all
Defined in:
lib/archimate/lint/duplicate_entities.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ DuplicateEntities

TODO: Add option to permit additional project specific stop words TODO: Do relationships after elements are merged



45
46
47
48
49
50
51
52
# File 'lib/archimate/lint/duplicate_entities.rb', line 45

def initialize(model)
  @model = model
  @dupes = nil
  @count = nil
  @word_count = {}
  @ignored_entity_types = %w(Junction AndJunction OrJunction)
  dupe_list
end

Instance Attribute Details

#word_countObject (readonly)

Returns the value of attribute word_count.



42
43
44
# File 'lib/archimate/lint/duplicate_entities.rb', line 42

def word_count
  @word_count
end

Instance Method Details

#countObject



54
55
56
# File 'lib/archimate/lint/duplicate_entities.rb', line 54

def count
  @dupes.reduce(0) { |total, (_tag, ary)| total + ary.size }
end

#each(&block) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/archimate/lint/duplicate_entities.rb', line 62

def each(&block)
  @dupes.keys.sort.each do |name|
    ary = @dupes[name]
    element_type = ary.first.type
    block.call(element_type, name, ary)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/archimate/lint/duplicate_entities.rb', line 58

def empty?
  count.zero?
end