Class: Hyrax::SingleUseLinkPresenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
app/presenters/hyrax/single_use_link_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link) ⇒ SingleUseLinkPresenter

Returns a new instance of SingleUseLinkPresenter.

Parameters:


10
11
12
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 10

def initialize(link)
  @link = link
end

Instance Attribute Details

Returns the value of attribute link


5
6
7
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 5

def link
  @link
end

Instance Method Details

#human_readable_expirationObject


14
15
16
17
18
19
20
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 14

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

26
27
28
29
30
31
32
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 26

def link_type
  if download?
    t('hyrax.single_use_links.download.type')
  else
    t('hyrax.single_use_links.show.type')
  end
end

#short_keyObject


22
23
24
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 22

def short_key
  link.downloadKey.first(6)
end

#url_helperObject


34
35
36
37
38
39
40
# File 'app/presenters/hyrax/single_use_link_presenter.rb', line 34

def url_helper
  if download?
    "download_single_use_link_url"
  else
    "show_single_use_link_url"
  end
end