Class: Hyrax::GoogleScholarPresenter
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- Hyrax::GoogleScholarPresenter
- Defined in:
- app/presenters/hyrax/google_scholar_presenter.rb
Overview
Handles presentation for google scholar meta tags.
Instance Method Summary collapse
-
#authors ⇒ Array<String>
An ordered array of author names.
-
#degree_grantor ⇒ String
A string representing the degree granting institution(s) as a semicolon delimited list.
-
#description ⇒ String
A description.
-
#first_page ⇒ String
(also: #firstpage)
A string representing the first page.
-
#issue ⇒ String
A string representing the journal issue.
-
#journal_title ⇒ String
A string representing the journal title.
-
#keywords ⇒ String
The keywords.
-
#last_page ⇒ String
(also: #lastpage)
A string representing the last page.
- #pdf_url ⇒ #to_s
-
#publication_date ⇒ String
The publication date.
-
#publisher ⇒ String
A string representing the publisher.
-
#scholarly? ⇒ Boolean
Whether this content is “scholarly” for Google Scholar’s purposes.
-
#title ⇒ String
Exactly one title; the same one every time.
-
#volume ⇒ String
A string representing the journal volume.
Instance Method Details
#authors ⇒ Array<String>
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 return object. if object.respond_to?(:ordered_authors) Array(object.creator) end |
#degree_grantor ⇒ String
Returns a string representing the degree granting institution(s) as a semicolon delimited list.
89 90 91 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 89 def degree_grantor Array(object.try(:degree_grantor)).join('; ') end |
#description ⇒ String
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_page ⇒ String Also known as: firstpage
Returns a string representing the first page.
113 114 115 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 113 def first_page Array(object.try(:page_start)).first || '' end |
#issue ⇒ String
Returns a string representing the journal issue.
107 108 109 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 107 def issue Array(object.try(:journal_issue)).first || '' end |
#journal_title ⇒ String
Returns a string representing the journal title.
95 96 97 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 95 def journal_title Array(object.try(:journal_title)).first || '' end |
#keywords ⇒ String
Returns the keywords.
55 56 57 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 55 def keywords Array(object.try(:keyword)).join('; ') end |
#last_page ⇒ String Also known as: lastpage
Returns a string representing the last page.
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
this should probably only return a present value if a PDF is available!
64 65 66 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 64 def pdf_url object.try(:download_url) end |
#publication_date ⇒ String
Returns the publication date.
70 71 72 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 70 def publication_date Array(object.try(:date_created)).first || '' end |
#publisher ⇒ String
Returns a string representing the publisher.
76 77 78 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 76 def publisher Array(object.try(:publisher)).join('; ') end |
#scholarly? ⇒ Boolean
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 |
#title ⇒ String
Returns exactly one title; the same one every time.
82 83 84 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 82 def title Array(object.try(:title)).sort.first || "" end |
#volume ⇒ String
Returns a string representing the journal volume.
101 102 103 |
# File 'app/presenters/hyrax/google_scholar_presenter.rb', line 101 def volume Array(object.try(:journal_volume)).first || '' end |