Class: Aspire::Object::ListItem
- 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
Constants included from Util
Instance Attribute Summary collapse
-
#digitisation ⇒ Aspire::Object::Digitisation
The digitisation details for the item.
-
#importance ⇒ String
The importance of the item.
-
#library_note ⇒ String
The internal library note for the item.
-
#local_control_number ⇒ String
The identifier of the resource in the local library management system.
-
#note ⇒ String
The public note for the item.
-
#resource ⇒ Aspire::Object::Resource
The resource for the item.
-
#student_note ⇒ String
The public note for the item.
-
#title(alt = nil) ⇒ String
Returns the resource title or public note if no resource is available.
Attributes inherited from ListBase
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(uri, factory, parent = nil, json: nil, ld: nil) ⇒ void
constructor
Initialises a new ListItem instance.
-
#length(item_type = nil) ⇒ Object
Returns the length of the list item.
-
#public_note ⇒ String
Returns the public (student or general) note.
-
#to_s ⇒ String
Returns a string representation of the ListItem instance (the citation title or note).
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
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
#digitisation ⇒ Aspire::Object::Digitisation
Returns the digitisation details for the item.
417 418 419 |
# File 'lib/aspire/object/list.rb', line 417 def digitisation @digitisation end |
#importance ⇒ String
Returns the importance of the item.
421 422 423 |
# File 'lib/aspire/object/list.rb', line 421 def importance @importance end |
#library_note ⇒ String
Returns 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_number ⇒ String
Returns 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 |
#note ⇒ String
Returns the public note for the item.
434 435 436 |
# File 'lib/aspire/object/list.rb', line 434 def note @note end |
#resource ⇒ Aspire::Object::Resource
Returns the resource for the item.
439 440 441 |
# File 'lib/aspire/object/list.rb', line 439 def resource @resource end |
#student_note ⇒ String
Returns 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
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
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_note ⇒ String
Returns the public (student or general) note
482 483 484 |
# File 'lib/aspire/object/list.rb', line 482 def public_note student_note || note end |
#to_s ⇒ String
Returns a string representation of the ListItem instance (the citation
title or note)
504 505 506 |
# File 'lib/aspire/object/list.rb', line 504 def to_s title(:public_note).to_s end |