Class: SourceMonitor::Items::NormalizedEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/items/normalized_entry.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, entry:, content_extractor: nil) ⇒ NormalizedEntry

Returns a new instance of NormalizedEntry.



14
15
16
17
18
# File 'lib/source_monitor/items/normalized_entry.rb', line 14

def initialize(source:, entry:, content_extractor: nil)
  @source = source
  @entry = entry
  @content_extractor = content_extractor || ItemCreator::ContentExtractor.new(source: source)
end

Class Method Details

.call(source:, entry:, content_extractor: nil) ⇒ Object



10
11
12
# File 'lib/source_monitor/items/normalized_entry.rb', line 10

def self.call(source:, entry:, content_extractor: nil)
  new(source: source, entry: entry, content_extractor: content_extractor).item_attributes
end

Instance Method Details

#attributesObject



20
21
22
# File 'lib/source_monitor/items/normalized_entry.rb', line 20

def attributes
  @attributes ||= parser.parse
end

#content_fingerprintObject



44
45
46
# File 'lib/source_monitor/items/normalized_entry.rb', line 44

def content_fingerprint
  attributes[:content_fingerprint]
end

#item_attributesObject



24
25
26
# File 'lib/source_monitor/items/normalized_entry.rb', line 24

def item_attributes
  attributes.merge(guid: item_guid)
end

#item_guidObject



40
41
42
# File 'lib/source_monitor/items/normalized_entry.rb', line 40

def item_guid
  normalized_guid.presence || content_fingerprint
end

#normalized_guidObject



32
33
34
# File 'lib/source_monitor/items/normalized_entry.rb', line 32

def normalized_guid
  raw_guid.present? ? raw_guid.downcase : nil
end

#raw_guidObject



28
29
30
# File 'lib/source_monitor/items/normalized_entry.rb', line 28

def raw_guid
  attributes[:guid]
end

#raw_guid_present?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/source_monitor/items/normalized_entry.rb', line 36

def raw_guid_present?
  normalized_guid.present?
end