Class: Textus::Step::Builtin::RssFetch

Inherits:
Fetch show all
Defined in:
lib/textus/step/builtin/rss_fetch.rb

Instance Attribute Summary

Attributes inherited from Textus::Step::Base

#name

Instance Method Summary collapse

Methods inherited from Fetch

required_kwargs

Methods inherited from Textus::Step::Base

kind, required_kwargs, step_name

Instance Method Details

#call(config:, args:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/textus/step/builtin/rss_fetch.rb', line 11

def call(config:, args:, **)
  _ = args
  doc = REXML::Document.new(config["bytes"].to_s)
  items = doc.elements.to_a("//item").map do |item|
    {
      "title" => item.elements["title"]&.text,
      "link" => item.elements["link"]&.text,
      "pubDate" => item.elements["pubDate"]&.text,
    }
  end
  { _meta: {}, body: YAML.dump(items) }
end