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.
-
#description ⇒ String
A description.
-
#keywords ⇒ String
The keywords.
- #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.
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 |
#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 |
#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 |
#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 |