Class: Hyrax::SingleUseLinkPresenter
- Inherits:
-
Object
- Object
- Hyrax::SingleUseLinkPresenter
- Includes:
- ActionView::Helpers::TranslationHelper
- Defined in:
- app/presenters/hyrax/single_use_link_presenter.rb
Instance Attribute Summary collapse
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
- #human_readable_expiration ⇒ Object
-
#initialize(link) ⇒ SingleUseLinkPresenter
constructor
A new instance of SingleUseLinkPresenter.
- #link_type ⇒ Object
- #short_key ⇒ Object
- #url_helper ⇒ Object
Constructor Details
#initialize(link) ⇒ SingleUseLinkPresenter
Returns a new instance of SingleUseLinkPresenter.
11 12 13 |
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 11 def initialize(link) @link = link end |
Instance Attribute Details
#link ⇒ Object (readonly)
Returns the value of attribute link.
6 7 8 |
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 6 def link @link end |
Instance Method Details
#human_readable_expiration ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 15 def human_readable_expiration if hours < 1 t('hyrax.single_use_links.expiration.lesser_time') else t('hyrax.single_use_links.expiration.time', value: hours) end end |
#link_type ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 27 def link_type if download? t('hyrax.single_use_links.download.type') else t('hyrax.single_use_links.show.type') end end |
#short_key ⇒ Object
23 24 25 |
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 23 def short_key link.download_key.first(6) end |
#url_helper ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 35 def url_helper if download? "download_single_use_link_url" else "show_single_use_link_url" end end |