Class: Dspace::Item

Inherits:
Object
  • Object
show all
Includes:
Builders::HashBuilder
Defined in:
lib/dspace/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Builders::HashBuilder

#obj2hash

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.build_metadatas(args['metadata'])
end

Instance Attribute Details

#archivedObject

Returns the value of attribute archived.



5
6
7
# File 'lib/dspace/item.rb', line 5

def archived
  @archived
end

#bit_streamsObject (readonly)

Returns the value of attribute bit_streams.



7
8
9
# File 'lib/dspace/item.rb', line 7

def bit_streams
  @bit_streams
end

#expandObject (readonly)

Returns the value of attribute expand.



7
8
9
# File 'lib/dspace/item.rb', line 7

def expand
  @expand
end

#handleObject (readonly)

Returns the value of attribute handle.



7
8
9
# File 'lib/dspace/item.rb', line 7

def handle
  @handle
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/dspace/item.rb', line 7

def id
  @id
end

#last_modifiedObject (readonly)

Returns the value of attribute last_modified.



7
8
9
# File 'lib/dspace/item.rb', line 7

def last_modified
  @last_modified
end

Returns the value of attribute link.



7
8
9
# File 'lib/dspace/item.rb', line 7

def link
  @link
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/dspace/item.rb', line 7

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/dspace/item.rb', line 5

def name
  @name
end

#parent_collectionObject (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_listObject (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_listObject (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

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/dspace/item.rb', line 7

def type
  @type
end

#withdrawnObject

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_metadataObject



57
58
59
# File 'lib/dspace/item.rb', line 57

def 
  @metadata = []
end

#to_hObject



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