summaryrefslogtreecommitdiff
path: root/new/lib/crys/processors/rss_processor.rb
blob: 8254bf4ae49f7858bc3edb7816abe6cea6ccf780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require_relative 'mixins/common_functions'
require_relative 'mixins/common_parts'

module Crys
  class RssProcessor
    def initialize(file_path:, image_dir:)
      @file_path = file_path
      rss_file = File.read(file_path)
      instance_eval(rss_file)
      @assets = []
      @image_dir = image_dir # just for api consistency
    end

    def parsed_pages
      [
        ProcessedPage.new(
          filename: rss.filename,
          content: rss.content,
          source: file_path,
          last_updated_at: Time.now
        )
      ]
    end

    def filename
      rss.filename
    end

    attr_reader :assets, :file_path

    private

    attr_reader :rss
  end
end