Sha256: 106cbcfff2c6dcb30e6cad28e12c4e3f73116ab01cd0ac0ae9c4891c5a3ca703

Contents?: true

Size: 598 Bytes

Versions: 3

Compression:

Stored size: 598 Bytes

Contents

module Stratify
  module Instapaper
    class Presenter
      delegate :url, :title, :description, :to => :@activity

      def initialize(activity)
        @activity = activity
      end

      def summary
        title.blank? ? url : title
      end

      def details
        join_fields_with_separator domain, description
      end

      def domain
        URI.parse(URI.escape(url)).host
      end

      private

      def separator
        "\u2022"
      end

      def join_fields_with_separator(*fields)
        fields.reject(&:blank?).join(" #{separator} ")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stratify-instapaper-0.1.4.1 lib/stratify-instapaper/presenter.rb
stratify-instapaper-0.1.4 lib/stratify-instapaper/presenter.rb
stratify-instapaper-0.1.3.1 lib/stratify-instapaper/presenter.rb