Class: Rssly::Serializers::Text

Inherits:
Serializer show all
Defined in:
lib/rssly/serializers.rb

Overview

Transforms a collection into a text representation

Direct Known Subclasses

HTML

Constant Summary collapse

ARTICLE_TEMPLATE =
<<-EOT
====== %{title} ======
Seen @ %{published}

%{summary}

Read on: %{url}

--

EOT

Instance Method Summary collapse

Methods inherited from Serializer

#initialize

Constructor Details

This class inherits a constructor from Rssly::Serializers::Serializer

Instance Method Details

#performObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/rssly/serializers.rb', line 28

def perform
  @collection.articles.reduce('') do |response, article|
    response + ARTICLE_TEMPLATE % {
      title: article.title,
      summary: article.summary,
      published: article.published,
      url: article.url
    }
  end
end