Class: Lcms::Engine::GenericPresenter

Inherits:
ResourcePresenter show all
Defined in:
app/presenters/lcms/engine/generic_presenter.rb

Instance Method Summary collapse

Methods inherited from ResourcePresenter

#categorized_downloads_list, #downloads_indent, #page_title, #subject_and_grade_title

Instance Method Details

#generic_titleObject



6
7
8
# File 'app/presenters/lcms/engine/generic_presenter.rb', line 6

def generic_title
  "#{subject.try(:upcase)} #{grades.to_str}"
end

#pdf_preview_downloadObject



20
21
22
# File 'app/presenters/lcms/engine/generic_presenter.rb', line 20

def pdf_preview_download
  resource_downloads.find { |d| d.download.main? && d.download.attachment_content_type == 'pdf' }
end

#preview?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'app/presenters/lcms/engine/generic_presenter.rb', line 14

def preview?
  downloads.any? { |d| d.main? && d.attachment_content_type == 'pdf' && RestClient.head(d.attachment_url) }
rescue RestClient::ExceptionWithResponse
  false
end

#type_nameObject



10
11
12
# File 'app/presenters/lcms/engine/generic_presenter.rb', line 10

def type_name
  I18n.t("resource_types.#{resource_type}")
end