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.

Returns:

  • (Array<String>)

    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

#descriptionString

Note:

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

Returns a description.

Returns:

  • (String)

    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

#keywordsString

Returns the keywords.

Returns:

  • (String)

    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

TODO:

this should probably only return a present value if a PDF is available!

Returns:

  • (#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

Returns the publication date.

Returns:

  • (String)

    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

#publisherString

Returns a string representing the publisher.

Returns:

  • (String)

    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

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.

Returns:

  • (Boolean)

    whether this content is “scholarly” for Google Scholar’s purposes. delegates to decorated object if possible.

See Also:



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

Returns exactly one title; the same one every time.

Returns:

  • (String)

    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