Module: DownloadsHelper
- Defined in:
- app/helpers/downloads_helper.rb
Instance Method Summary collapse
-
#download_expires_tag(download) ⇒ String?
E.g.
- #download_file_api_url(download) ⇒ Object
- #download_link(download) ⇒ Object
-
#download_status(download) ⇒ Hash
Calculated attributes used in /download responses.
- #download_tag(download) ⇒ Object
Instance Method Details
#download_expires_tag(download) ⇒ String?
Returns e.g. "in 3 days", or "3 days ago" once expired.
14 15 16 17 18 19 |
# File 'app/helpers/downloads_helper.rb', line 14 def download_expires_tag(download) return nil if download.nil? download.expired? ? "#{time_ago_in_words(download.expires)} ago" : "in #{time_ago_in_words(download.expires)}" end |
#download_file_api_url(download) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/helpers/downloads_helper.rb', line 21 def download_file_api_url(download) return nil if download.nil? if sessions_current_project.api_access_token api_v1_api_download_file_url(download, project_token: sessions_current_project.api_access_token) else nil end end |
#download_link(download) ⇒ Object
7 8 9 10 |
# File 'app/helpers/downloads_helper.rb', line 7 def download_link(download) return nil if download.nil? link_to(download_tag(download), download.) end |
#download_status(download) ⇒ Hash
Returns calculated attributes used in /download responses.
32 33 34 35 36 37 38 |
# File 'app/helpers/downloads_helper.rb', line 32 def download_status(download) return nil if download.nil? || !download.persisted? return { ready: download.ready?, expired: download.expired? } end |
#download_tag(download) ⇒ Object
2 3 4 5 |
# File 'app/helpers/downloads_helper.rb', line 2 def download_tag(download) return nil if download.nil? "[#{download.name}] #{download.description}".html_safe end |