Class: Aspire::Object::ListItem

Inherits:
ListBase show all
Defined in:
lib/aspire/object/list.rb

Overview

Represents a reading list item (citation) in the Aspire API

Constant Summary

Constants inherited from ListBase

Aspire::Object::ListBase::KEY_PREFIX

Constants inherited from Base

Base::STRIP_HTML

Constants included from Util

Util::LD_API_URI

Instance Attribute Summary collapse

Attributes inherited from ListBase

#entries, #parent

Attributes inherited from Base

#factory, #uri

Instance Method Summary collapse

Methods inherited from ListBase

#each, #each_item, #each_section, #get_entries, #items, #parent_list, #parent_lists, #parent_section, #parent_sections, #parents, #parents_include?, #sections

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, factory, parent = nil, json: nil, ld: nil) ⇒ void

Initialises a new ListItem instance

Parameters:

  • uri (String)

    the reading list object URI (item/list/section)

  • factory (Aspire::Object::Factory)

    a factory returning ReadingListBase subclass instances

  • parent (Aspire::Object::ListBase) (defaults to: nil)

    the parent reading list object of this object

  • json (Hash) (defaults to: nil)

    the parsed JSON data from the Aspire JSON API

  • ld (Hash) (defaults to: nil)

    the parsed JSON data from the Aspire linked data API



458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/aspire/object/list.rb', line 458

def initialize(uri, factory, parent = nil, json: nil, ld: nil)
  super(uri, factory, parent, json: json, ld: ld)
  json ||= init_list_items
  init_digitisation(json)
  init_resource(json)
  self.importance = get_property('importance', json)
  self.library_note = get_property('libraryNote', json)
  self.local_control_number = get_property('lcn', json)
  self.note = get_property('note', json)
  self.student_note = get_property('studentNote', json)
  self.title = get_property('title', json)
end

Instance Attribute Details

#digitisationAspire::Object::Digitisation

Returns the digitisation details for the item.

Returns:



417
418
419
# File 'lib/aspire/object/list.rb', line 417

def digitisation
  @digitisation
end

#importanceString

Returns the importance of the item.

Returns:

  • (String)

    the importance of the item



421
422
423
# File 'lib/aspire/object/list.rb', line 421

def importance
  @importance
end

#library_noteString

Returns the internal library note for the item.

Returns:

  • (String)

    the internal library note for the item



425
426
427
# File 'lib/aspire/object/list.rb', line 425

def library_note
  @library_note
end

#local_control_numberString

Returns the identifier of the resource in the local library management system.

Returns:

  • (String)

    the identifier of the resource in the local library management system



430
431
432
# File 'lib/aspire/object/list.rb', line 430

def local_control_number
  @local_control_number
end

#noteString

Returns the public note for the item.

Returns:

  • (String)

    the public note for the item



434
435
436
# File 'lib/aspire/object/list.rb', line 434

def note
  @note
end

#resourceAspire::Object::Resource

Returns the resource for the item.

Returns:



439
440
441
# File 'lib/aspire/object/list.rb', line 439

def resource
  @resource
end

#student_noteString

Returns the public note for the item.

Returns:

  • (String)

    the public note for the item



443
444
445
# File 'lib/aspire/object/list.rb', line 443

def student_note
  @student_note
end

#title(alt = nil) ⇒ String

Returns the resource title or public note if no resource is available

Parameters:

  • alt (Symbol) (defaults to: nil)

    the alternative if no resource is available :library_note or :private_note = the library note :note = the student note, or the library note if no student note is

    available
    

    :public_note, :student_note = the student note :uri = the list item URI

Returns:

  • (String)

    the resource title or alternative



447
448
449
# File 'lib/aspire/object/list.rb', line 447

def title
  @title
end

Instance Method Details

#length(item_type = nil) ⇒ Object

Returns the length of the list item

See Also:

  • Aspire::Object::ListItem.(Aspire(Aspire::Object(Aspire::Object::ListBase(Aspire::Object::ListBase#length)


473
474
475
476
477
478
# File 'lib/aspire/object/list.rb', line 473

def length(item_type = nil)
  item_type ||= :item
  # List items return an item length of 1 to enable summation of
  #   list/section lengths
  item_type == :item ? 1 : super(item_type)
end

#public_noteString

Returns the public (student or general) note

Returns:

  • (String)

    the student note or general note



482
483
484
# File 'lib/aspire/object/list.rb', line 482

def public_note
  student_note || note
end

#to_sString

Returns a string representation of the ListItem instance (the citation

title or note)

Returns:

  • (String)

    the string representation of the ListItem instance



504
505
506
# File 'lib/aspire/object/list.rb', line 504

def to_s
  title(:public_note).to_s
end