Class: Aspire::Object::Resource

Inherits:
Base
  • Object
show all
Includes:
ResourcePropertyMixin, ResourceShortcutsMixin
Defined in:
lib/aspire/object/resource.rb

Overview

Represents a resource in the Aspire API

Constant Summary collapse

PAGE_RANGE =
/(?<start>[\da-zA-Z]*)\s*-\s*(?<end>[\da-zA-Z]*)/

Constants included from ResourcePropertyMixin

Aspire::Object::ResourcePropertyMixin::CITATION_PROPERTIES

Constants inherited from Base

Base::STRIP_HTML

Constants included from Util

Util::LD_API_URI

Instance Attribute Summary collapse

Attributes inherited from Base

#factory, #uri

Instance Method Summary collapse

Methods included from ResourceShortcutsMixin

#article_title, #book_title, #chapter_title, #citation_title, #journal_title, #part_of_title, #part_of_title_by_type, #part_title, #part_title_by_type

Methods included from ResourcePropertyMixin

#get_property_name_from_method, #method_missing, #respond_to_missing?

Methods inherited from Base

#get_boolean, #get_date, #get_property

Methods included from Util

#child_url?, #duration, #id_from_uri, #item?, #linked_data, #linked_data_path, #list?, #list_url?, #module?, #parent_url?, #parse_url, #resource?, #section?, #url_for_comparison, #url_path, #user?

Constructor Details

#initialize(uri = nil, factory = nil, json: nil, ld: nil) ⇒ void

Initialises a new Resource instance

Parameters:

  • json (Hash) (defaults to: nil)

    the resource data from the Aspire JSON API

  • ld (Hash) (defaults to: nil)

    the resource data from the Aspire linked data API



250
251
252
253
254
255
256
257
258
259
260
# File 'lib/aspire/object/resource.rb', line 250

def initialize(uri = nil, factory = nil, json: nil, ld: nil)
  uri ||= json ? json['uri'] : nil
  super(uri, factory)
  return unless json
  init_general(json)
  init_components(json)
  init_edition(json)
  init_identifiers(json)
  init_part(json)
  init_publication(json)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Aspire::Object::ResourcePropertyMixin

Instance Attribute Details

#authorsArray<String>

Returns the list of authors of the resource.

Returns:

  • (Array<String>)

    the list of authors of the resource



140
141
142
# File 'lib/aspire/object/resource.rb', line 140

def authors
  @authors
end

#book_jacket_urlString

Returns the book jacket image URL.

Returns:

  • (String)

    the book jacket image URL



144
145
146
# File 'lib/aspire/object/resource.rb', line 144

def book_jacket_url
  @book_jacket_url
end

#dateString

Returns the date of publication.

Returns:

  • (String)

    the date of publication



148
149
150
# File 'lib/aspire/object/resource.rb', line 148

def date
  @date
end

#doiString

Returns the DOI for the resource.

Returns:

  • (String)

    the DOI for the resource



152
153
154
# File 'lib/aspire/object/resource.rb', line 152

def doi
  @doi
end

#editionString

Returns the edition.

Returns:

  • (String)

    the edition



156
157
158
# File 'lib/aspire/object/resource.rb', line 156

def edition
  @edition
end

#edition_dataBoolean

Returns true if edition data is available.

Returns:

  • (Boolean)

    true if edition data is available



160
161
162
# File 'lib/aspire/object/resource.rb', line 160

def edition_data
  @edition_data
end

#eissnString

Returns the electronic ISSN for the resource.

Returns:

  • (String)

    the electronic ISSN for the resource



164
165
166
# File 'lib/aspire/object/resource.rb', line 164

def eissn
  @eissn
end

#has_partArray<Aspire::Object::Resource>

Returns child resources.

Returns:



168
169
170
# File 'lib/aspire/object/resource.rb', line 168

def has_part
  @has_part
end

#is_part_ofArray<Aspire::Object::Resource>

Returns parent resources.

Returns:



172
173
174
# File 'lib/aspire/object/resource.rb', line 172

def is_part_of
  @is_part_of
end

#isbn10String

Returns the 10-digit ISBN for the resource.

Returns:

  • (String)

    the 10-digit ISBN for the resource



176
177
178
# File 'lib/aspire/object/resource.rb', line 176

def isbn10
  @isbn10
end

#isbn13String

Returns the 13-digit ISBN for the resource.

Returns:

  • (String)

    the 13-digit ISBN for the resource



180
181
182
# File 'lib/aspire/object/resource.rb', line 180

def isbn13
  @isbn13
end

#isbnsArray<String>

Returns the list of ISBNs for the resource.

Returns:

  • (Array<String>)

    the list of ISBNs for the resource



184
185
186
# File 'lib/aspire/object/resource.rb', line 184

def isbns
  @isbns
end

#issnArray<String>

Returns the ISSN for the resource.

Returns:

  • (Array<String>)

    the ISSN for the resource



188
189
190
# File 'lib/aspire/object/resource.rb', line 188

def issn
  @issn
end

#issueString

Returns the issue.

Returns:

  • (String)

    the issue



192
193
194
# File 'lib/aspire/object/resource.rb', line 192

def issue
  @issue
end

#issuedString

Returns the issue date.

Returns:

  • (String)

    the issue date



196
197
198
# File 'lib/aspire/object/resource.rb', line 196

def issued
  @issued
end

#latest_editionBoolean

Returns true if this is the latest edition.

Returns:

  • (Boolean)

    true if this is the latest edition



200
201
202
# File 'lib/aspire/object/resource.rb', line 200

def latest_edition
  @latest_edition
end

#local_control_numberString

Returns the local control number in the library catalogue.

Returns:

  • (String)

    the local control number in the library catalogue



204
205
206
# File 'lib/aspire/object/resource.rb', line 204

def local_control_number
  @local_control_number
end

#online_resourceBoolean

Returns true if this is an online resource.

Returns:

  • (Boolean)

    true if this is an online resource



208
209
210
# File 'lib/aspire/object/resource.rb', line 208

def online_resource
  @online_resource
end

#pageString

Returns the page range.

Returns:

  • (String)

    the page range



212
213
214
# File 'lib/aspire/object/resource.rb', line 212

def page
  @page
end

#page_endString

Returns the end page.

Returns:

  • (String)

    the end page



216
217
218
# File 'lib/aspire/object/resource.rb', line 216

def page_end
  @page_end
end

#page_startString

Returns the start page.

Returns:

  • (String)

    the start page



220
221
222
# File 'lib/aspire/object/resource.rb', line 220

def page_start
  @page_start
end

#place_of_publicationString

Returns the place of publication.

Returns:

  • (String)

    the place of publication



224
225
226
# File 'lib/aspire/object/resource.rb', line 224

def place_of_publication
  @place_of_publication
end

#publisherString

Returns the publisher.

Returns:

  • (String)

    the publisher



228
229
230
# File 'lib/aspire/object/resource.rb', line 228

def publisher
  @publisher
end

#titleString

Returns the title of the resource.

Returns:

  • (String)

    the title of the resource



232
233
234
# File 'lib/aspire/object/resource.rb', line 232

def title
  @title
end

#typeString

Returns the type of the resource.

Returns:

  • (String)

    the type of the resource



236
237
238
# File 'lib/aspire/object/resource.rb', line 236

def type
  @type
end

#urlString

Returns the URL of the resource.

Returns:

  • (String)

    the URL of the resource



240
241
242
# File 'lib/aspire/object/resource.rb', line 240

def url
  @url
end

#volumeString

Returns the volume.

Returns:

  • (String)

    the volume



244
245
246
# File 'lib/aspire/object/resource.rb', line 244

def volume
  @volume
end

Instance Method Details

#page_rangeString

Returns the page range spanned by the page_start and page_end properties

Returns:

  • (String)

    the page range “start-end” or page number



282
283
284
285
286
# File 'lib/aspire/object/resource.rb', line 282

def page_range
  return @page_start if @page_end.nil? || @page_start == @page_end
  return @page_end if @page_start.nil?
  "#{@page_start}-#{@page_end}"
end

#to_sString

Returns a string representation of the resource (the title)

Returns:

  • (String)

    the string representation of the resource



290
291
292
# File 'lib/aspire/object/resource.rb', line 290

def to_s
  title
end