Class: Hyrax::GoogleScholarPresenter

Inherits:
Draper::Decorator
  • Object
show all
Defined in:
app/presenters/hyrax/google_scholar_presenter.rb

Overview

Handles presentation for google scholar meta tags.

Examples:

my_book = Monograph.new(title: ['On Moomins'], creator: ['Tove', 'Lars'])
scholar = GoogleScholarPresenter.new(my_book)

scholar.title => 'On Moomins'

See Also:

Instance Method Summary collapse

Instance Method Details

#authorsArray<String>

Note:

Google Scholar cares about author order. when possible, this should return the othors in order. delegates to #ordered_authors when available.

Returns an ordered array of author names.



38
39
40
41
42
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 38

def authors
  return object.ordered_authors if object.respond_to?(:ordered_authors)

  Array(object.creator)
end

#degree_grantorString



89
90
91
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 89

def degree_grantor
  Array(object.try(:degree_grantor)).join('; ')
end

#descriptionString

Note:

falls back on #title if no description can be found. this probably isn't great.

Returns a description.



49
50
51
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 49

def description
  (Array(object.try(:description)).first || title).truncate(200)
end

#first_pageString Also known as: firstpage



113
114
115
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 113

def first_page
  Array(object.try(:page_start)).first || ''
end

#issueString



107
108
109
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 107

def issue
  Array(object.try(:journal_issue)).first || ''
end

#journal_titleString



95
96
97
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 95

def journal_title
  Array(object.try(:journal_title)).first || ''
end

#keywordsString



55
56
57
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 55

def keywords
  Array(object.try(:keyword)).join('; ')
end

#last_pageString Also known as: lastpage



120
121
122
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 120

def last_page
  Array(object.try(:page_end)).first || ''
end

#pdf_url#to_s



64
65
66
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 64

def pdf_url
  object.try(:download_url)
end

#publication_dateString



70
71
72
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 70

def publication_date
  Array(object.try(:date_created)).first || ''
end

#publisherString



76
77
78
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 76

def publisher
  Array(object.try(:publisher)).join('; ')
end

#scholarly?Boolean

Note:

Scholar content inclusion docs indicate we should embed metadata for "scholarly articles - journal papers, conference papers, technical reports, or their drafts, dissertations, pre-prints, post-prints, or abstracts." Implementations should try to return false for other content.

Returns whether this content is "scholarly" for Google Scholar's purposes. delegates to decorated object if possible.



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

def scholarly?
  return object.scholarly? if object.respond_to?(:scholarly?)

  true
end

#titleString



82
83
84
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 82

def title
  Array(object.try(:title)).sort.first || ""
end

#volumeString



101
102
103
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 101

def volume
  Array(object.try(:journal_volume)).first || ''
end