Module: Aspire::Object::ResourceShortcutsMixin

Included in:
Resource
Defined in:
lib/aspire/object/resource.rb

Overview

Shortcut methods

Instance Method Summary collapse

Instance Method Details

#article_titleString?

Returns the title of the journal article associated with this resource

Returns:

  • (String, nil)

    the journal article title or nil if not applicable



72
73
74
# File 'lib/aspire/object/resource.rb', line 72

def article_title
  part_title_by_type('Article')
end

#book_titleString?

Returns the title of the book associated with this resource

Returns:

  • (String, nil)

    the book title or nil if not applicable



78
79
80
# File 'lib/aspire/object/resource.rb', line 78

def book_title
  part_of_title_by_type('Book')
end

#chapter_titleString?

Returns the title of the book chapter associated with this resource

Returns:

  • (String, nil)

    the book chapter title or nil if not applicable



84
85
86
# File 'lib/aspire/object/resource.rb', line 84

def chapter_title
  part_title_by_type('Chapter')
end

#citation_titleString

Returns the resource title as expected by the Alma reading list loader (Article = article title, book = book title, other = resource title)

Returns:

  • (String)

    the citation title



91
92
93
# File 'lib/aspire/object/resource.rb', line 91

def citation_title
  article_title || book_title || title
end

#journal_titleString?

Returns the title of the journal associated with this resource

Returns:

  • (String, nil)

    the journal title or nil if not applicable



97
98
99
# File 'lib/aspire/object/resource.rb', line 97

def journal_title
  part_of_title_by_type('Journal')
end

#part_of_titleString

Returns the title of the parent resource (book, journal etc.)

Returns:

  • (String)

    the title of the parent resource



103
104
105
# File 'lib/aspire/object/resource.rb', line 103

def part_of_title
  is_part_of ? is_part_of.title : nil
end

#part_of_title_by_type(res_type) ⇒ String

Returns the title of the parent resource (book, journal etc.)

Returns:

  • (String)

    the title of the parent resource



109
110
111
112
113
# File 'lib/aspire/object/resource.rb', line 109

def part_of_title_by_type(res_type)
  return title if type == res_type
  return is_part_of.title if is_part_of && is_part_of.type == res_type
  nil
end

#part_titleString

Returns the title of the part (book chapter, journal article etc.)

Returns:

  • (String)

    the title of the part



117
118
119
# File 'lib/aspire/object/resource.rb', line 117

def part_title
  has_part ? has_part.title : nil
end

#part_title_by_type(res_type) ⇒ String

Returns the title of the part

Parameters:

  • res_type (String)

    the type of the resource

Returns:

  • (String)

    the title of the part



124
125
126
127
128
# File 'lib/aspire/object/resource.rb', line 124

def part_title_by_type(res_type)
  return title if type == res_type
  return has_part.title if has_part && has_part.type == res_type
  nil
end