Class: SourceMonitor::Items::NormalizedEntry
- Inherits:
-
Object
- Object
- SourceMonitor::Items::NormalizedEntry
- Defined in:
- lib/source_monitor/items/normalized_entry.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #content_fingerprint ⇒ Object
-
#initialize(source:, entry:, content_extractor: nil) ⇒ NormalizedEntry
constructor
A new instance of NormalizedEntry.
- #item_attributes ⇒ Object
- #item_guid ⇒ Object
- #normalized_guid ⇒ Object
- #raw_guid ⇒ Object
- #raw_guid_present? ⇒ Boolean
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
#attributes ⇒ Object
20 21 22 |
# File 'lib/source_monitor/items/normalized_entry.rb', line 20 def attributes @attributes ||= parser.parse end |
#content_fingerprint ⇒ Object
44 45 46 |
# File 'lib/source_monitor/items/normalized_entry.rb', line 44 def content_fingerprint attributes[:content_fingerprint] end |
#item_attributes ⇒ Object
24 25 26 |
# File 'lib/source_monitor/items/normalized_entry.rb', line 24 def item_attributes attributes.merge(guid: item_guid) end |
#item_guid ⇒ Object
40 41 42 |
# File 'lib/source_monitor/items/normalized_entry.rb', line 40 def item_guid normalized_guid.presence || content_fingerprint end |
#normalized_guid ⇒ Object
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_guid ⇒ Object
28 29 30 |
# File 'lib/source_monitor/items/normalized_entry.rb', line 28 def raw_guid attributes[:guid] end |
#raw_guid_present? ⇒ Boolean
36 37 38 |
# File 'lib/source_monitor/items/normalized_entry.rb', line 36 def raw_guid_present? normalized_guid.present? end |