class ArticleFixtureGen::Data::WordEntryComparator

Compares two WordEntry instances to each other, per comparison interface.

Public Class Methods

call(obj, other) click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 24
def self.call(obj, other)
  WordEntryComparator.new(obj, other).call
end
new(obj, other) click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 35
def initialize(obj, other)
  @obj = obj
  @other = other
  self
end

Public Instance Methods

call() click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 28
def call
  Internals.first_nonzero([dom_difference, index_difference]) || 0
  # [dom_difference, index_difference].reject(&:zero?).first
end

Private Instance Methods

dom_difference() click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 43
def dom_difference
  @obj.dom_position <=> @other.dom_position
end
index_difference() click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 47
def index_difference
  @obj.word_index <=> @other.word_index
end