Class: Aspire::Object::List
- Includes:
- Properties
- Defined in:
- lib/aspire/object/list.rb
Overview
Represents a reading list in the Aspire API
Constant Summary
Constants included from Properties
Properties::AIISO_CODE, Properties::AIISO_NAME, Properties::CREATED, Properties::DESCRIPTION, Properties::HAS_CREATOR, Properties::HAS_OWNER, Properties::LAST_PUBLISHED, Properties::LAST_UPDATED, Properties::NAME, Properties::PUBLISHED_BY, Properties::USED_BY
Constants inherited from ListBase
Aspire::Object::ListBase::KEY_PREFIX
Constants inherited from Base
Constants included from Util
Instance Attribute Summary collapse
-
#created ⇒ DateTime
The creation timestamp of the list.
-
#creator ⇒ Array<Aspire::Object::User>
The reading list creators.
-
#description ⇒ String
The description of the list.
-
#items ⇒ Hash<String, Aspire::Object::ListItem>
A hash of ListItems indexed by item URI.
-
#last_published ⇒ DateTime
The timestamp of the most recent list publication.
-
#last_updated ⇒ DateTime
The timestamp of the most recent list update.
-
#modules ⇒ Array<Aspire::Object::Module>
The modules referencing this list.
-
#name ⇒ String
The reading list name.
-
#owner ⇒ Aspire::Object::User
The list owner.
-
#publisher ⇒ Aspire::Object::User
The list publisher.
-
#time_period ⇒ Aspire::Object::TimePeriod
The period covered by the list.
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 List instance.
-
#length(item_type = nil) ⇒ Object
Returns the number of items in the list.
-
#to_s ⇒ String
Returns a string representation of the List instance (the name).
Methods inherited from ListBase
#each, #each_item, #each_section, #get_entries, #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 List instance
266 267 268 269 270 271 272 273 274 275 |
# File 'lib/aspire/object/list.rb', line 266 def initialize(uri, factory, parent = nil, json: nil, ld: nil) # Set properties from the Reading Lists JSON API # - this must be called before the superclass constructor so that item # details are available init_json_data(uri, factory, json) # Initialise the superclass super(uri, factory, parent, json: json, ld: ld) # Set properties from the linked data API data init_linked_data(ld) end |
Instance Attribute Details
#created ⇒ DateTime
Returns the creation timestamp of the list.
214 215 216 |
# File 'lib/aspire/object/list.rb', line 214 def created @created end |
#creator ⇒ Array<Aspire::Object::User>
Returns the reading list creators.
218 219 220 |
# File 'lib/aspire/object/list.rb', line 218 def creator @creator end |
#description ⇒ String
Returns the description of the list.
222 223 224 |
# File 'lib/aspire/object/list.rb', line 222 def description @description end |
#items ⇒ Hash<String, Aspire::Object::ListItem>
Returns a hash of ListItems indexed by item URI.
227 228 229 |
# File 'lib/aspire/object/list.rb', line 227 def items @items end |
#last_published ⇒ DateTime
Returns the timestamp of the most recent list publication.
231 232 233 |
# File 'lib/aspire/object/list.rb', line 231 def last_published @last_published end |
#last_updated ⇒ DateTime
Returns the timestamp of the most recent list update.
235 236 237 |
# File 'lib/aspire/object/list.rb', line 235 def last_updated @last_updated end |
#modules ⇒ Array<Aspire::Object::Module>
Returns the modules referencing this list.
240 241 242 |
# File 'lib/aspire/object/list.rb', line 240 def modules @modules end |
#name ⇒ String
Returns the reading list name.
244 245 246 |
# File 'lib/aspire/object/list.rb', line 244 def name @name end |
#owner ⇒ Aspire::Object::User
Returns the list owner.
248 249 250 |
# File 'lib/aspire/object/list.rb', line 248 def owner @owner end |
#publisher ⇒ Aspire::Object::User
Returns the list publisher.
252 253 254 |
# File 'lib/aspire/object/list.rb', line 252 def publisher @publisher end |
#time_period ⇒ Aspire::Object::TimePeriod
Returns the period covered by the list.
256 257 258 |
# File 'lib/aspire/object/list.rb', line 256 def time_period @time_period end |
Instance Method Details
#length(item_type = nil) ⇒ Object
Returns the number of items in the list
279 280 281 282 283 284 |
# File 'lib/aspire/object/list.rb', line 279 def length(item_type = nil) item_type ||= :item # The item length of a list is the length of the items property, # avoiding the need to sum list entry lengths item_type == :item ? items.length : super(item_type) end |
#to_s ⇒ String
Returns a string representation of the List instance (the name)
288 289 290 |
# File 'lib/aspire/object/list.rb', line 288 def to_s name || super end |