Sha256: 0d321ef60f89ba3af1fd074114f7334da1cce36991927c77403901bd18e11659

Contents?: true

Size: 765 Bytes

Versions: 6

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

module ViewHelpers
  # Returns today's date in Day, Date Month Year format
  #
  # @return [String]
  def today
    Time.now.strftime('%A, %d %B %Y')
  end

  # Returns the current time in month day year hour:minute:second format
  #
  # @return [String]
  def last_updated
    Time.now.strftime('%d %b %Y %H:%M:%S')
  end

  # Returns a string with anchor tag links to each Feed generated on the page
  #
  # @return [String]
  def quick_nav(feeds)
    feeds.select { |feed| feed.articles.size.positive? }
         .each_with_index.inject('') do |string, (feed, index)|
      string += "<a href='#feed-#{index}' class='quick-nav-item'>#{feed.title} <div class='circle'>#{feed.articles.size}</div></a>"
      string
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mako_rss-0.2.5 lib/mako/view_helpers.rb
mako_rss-0.2.3 lib/mako/view_helpers.rb
mako_rss-0.2.2 lib/mako/view_helpers.rb
mako_rss-0.2.1 lib/mako/view_helpers.rb
mako_rss-0.2.0 lib/mako/view_helpers.rb
mako_rss-0.1.0 lib/mako/view_helpers.rb