Module: Nightlight::PagesHelper
- Defined in:
- app/helpers/nightlight/pages_helper.rb
Instance Method Summary collapse
Instance Method Details
#avg_page_brightness(pages) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/helpers/nightlight/pages_helper.rb', line 4 def avg_page_brightness pages if pages.any? avg = pages.map(&:brightness).sum.to_f / pages.size.to_f avg.to_i else 0 end end |
#last_checked_at(page) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/nightlight/pages_helper.rb', line 18 def last_checked_at page if page.last_checked_at "last checked #{time_ago_in_words(page.last_checked_at)} ago" else "last checked ??" end end |
#link_to_page(page) ⇒ Object
13 14 15 16 |
# File 'app/helpers/nightlight/pages_helper.rb', line 13 def link_to_page page path = page.sample_path.presence || page.path link_to page.path, path, target: '_blank' end |