Class: Dspace::Item
- Inherits:
-
Object
- Object
- Dspace::Item
- Includes:
- Builders::HashBuilder
- Defined in:
- lib/dspace/item.rb
Instance Attribute Summary collapse
-
#archived ⇒ Object
Returns the value of attribute archived.
-
#bit_streams ⇒ Object
readonly
Returns the value of attribute bit_streams.
-
#expand ⇒ Object
readonly
Returns the value of attribute expand.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_modified ⇒ Object
readonly
Returns the value of attribute last_modified.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_collection ⇒ Object
readonly
Returns the value of attribute parent_collection.
-
#parent_collection_list ⇒ Object
readonly
Returns the value of attribute parent_collection_list.
-
#parent_community_list ⇒ Object
readonly
Returns the value of attribute parent_community_list.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#withdrawn ⇒ Object
Returns the value of attribute withdrawn.
Instance Method Summary collapse
- #add_metadata(key, value, language) ⇒ Object
-
#initialize(args) ⇒ Item
constructor
A new instance of Item.
- #reset_metadata ⇒ Object
- #to_h ⇒ Object
Methods included from Builders::HashBuilder
Constructor Details
#initialize(args) ⇒ Item
Returns a new instance of Item.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dspace/item.rb', line 11 def initialize args @id = args['id'] @name = args['name'] @handle = args['handle'] @type = args['type'] @link = args['link'] @last_modified = args['lastModified'] @parent_collection = Dspace::Collection.new(args['parentCollection']) unless args['parentCollection'].nil? @parent_collection_list = Dspace::Builders::ModelBuilder.build_collections(args['parentCollectionList']) @parent_community_list = Dspace::Builders::ModelBuilder.build_communities(args['parentCommunityList']) @bit_streams = Dspace::Builders::ModelBuilder.build_bitstreams(args['bitstreams']) @archived = args['archived'] @withdrawn = args['withdrawn'] @expand = args['expand'] @metadata = Dspace::Builders::ModelBuilder.(args['metadata']) end |
Instance Attribute Details
#archived ⇒ Object
Returns the value of attribute archived.
5 6 7 |
# File 'lib/dspace/item.rb', line 5 def archived @archived end |
#bit_streams ⇒ Object (readonly)
Returns the value of attribute bit_streams.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def bit_streams @bit_streams end |
#expand ⇒ Object (readonly)
Returns the value of attribute expand.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def @expand end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def handle @handle end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def id @id end |
#last_modified ⇒ Object (readonly)
Returns the value of attribute last_modified.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def last_modified @last_modified end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def link @link end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/dspace/item.rb', line 5 def name @name end |
#parent_collection ⇒ Object (readonly)
Returns the value of attribute parent_collection.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def parent_collection @parent_collection end |
#parent_collection_list ⇒ Object (readonly)
Returns the value of attribute parent_collection_list.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def parent_collection_list @parent_collection_list end |
#parent_community_list ⇒ Object (readonly)
Returns the value of attribute parent_community_list.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def parent_community_list @parent_community_list end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/dspace/item.rb', line 7 def type @type end |
#withdrawn ⇒ Object
Returns the value of attribute withdrawn.
5 6 7 |
# File 'lib/dspace/item.rb', line 5 def withdrawn @withdrawn end |
Instance Method Details
#add_metadata(key, value, language) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/dspace/item.rb', line 47 def (key, value, language) m = {} m['key'] = key m['value'] = value m['language'] = language || "" @metadata << Dspace::Metadata.new(m) @metadata end |
#reset_metadata ⇒ Object
57 58 59 |
# File 'lib/dspace/item.rb', line 57 def @metadata = [] end |
#to_h ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dspace/item.rb', line 28 def to_h { id: @id, name: @name, handle: @handle, type: @type, link: @link, lastModified: @last_modified, parentCollection: @parent_collection.to_h, parentCollectionList: obj2hash(@parent_collection_list), parentCommunityList: obj2hash(@parent_community_list), bitstreams: obj2hash(@bit_streams), archived: @archived, withdrawn: @withdrawn, expand: @expand, metadata: obj2hash(@metadata) } end |