Module: ViewHelpers

Included in:
Mako::Core
Defined in:
lib/mako/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#last_updatedString

Returns the current time in month day year hour:minute:second format

Returns:

  • (String)


14
15
16
# File 'lib/mako/view_helpers.rb', line 14

def last_updated
  Time.now.strftime('%d %b %Y %H:%M:%S')
end

#quick_nav(feeds) ⇒ String

Returns a string with anchor tag links to each Feed generated on the page

Returns:

  • (String)


21
22
23
24
25
26
27
# File 'lib/mako/view_helpers.rb', line 21

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

#todayString

Returns today’s date in Day, Date Month Year format

Returns:

  • (String)


7
8
9
# File 'lib/mako/view_helpers.rb', line 7

def today
  Time.now.strftime('%A, %d %B %Y')
end