Class: Sufia::CollectionPresenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper, Hydra::Presenter
Defined in:
app/presenters/sufia/collection_presenter.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/presenters/sufia/collection_presenter.rb', line 20

def [](key)
  case key
    when :size
      size
    when :total_items
      total_items
    else
      super
  end
end

#sizeObject



31
32
33
# File 'app/presenters/sufia/collection_presenter.rb', line 31

def size
  number_to_human_size(model.bytes)
end

#terms_with_valuesObject

Depositor and permissions are not displayed in app/views/collections/_show_descriptions.html.erb so don’t include them in ‘terms’. delegate :depositor, :permissions, to: :model



16
17
18
# File 'app/presenters/sufia/collection_presenter.rb', line 16

def terms_with_values
  terms.select { |t| self[t].present? }
end

#total_itemsObject



35
36
37
# File 'app/presenters/sufia/collection_presenter.rb', line 35

def total_items
  model.members.count
end