Class: Fedora::Datastream

Inherits:
BaseObject show all
Defined in:
lib/fedora/datastream.rb

Direct Known Subclasses

ActiveFedora::Datastream

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#attributes, #blob, #errors, #new_object

Instance Method Summary collapse

Methods inherited from BaseObject

#[], #new_object?

Constructor Details

#initialize(attrs = {}) ⇒ Datastream

Returns a new instance of Datastream.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fedora/datastream.rb', line 8

def initialize(attrs = {})
  super
  if attrs
    if attrs[:mime_type] 
      self.mime_type = attrs[:mime_type]
    elsif attrs[:mimeType] 
      self.mime_type = attrs[:mimeType]
    end 
  end
  self.control_group='M' if @attributes[:mimeType]
end

Instance Attribute Details

#mime_typeObject

Returns the value of attribute mime_type.



6
7
8
# File 'lib/fedora/datastream.rb', line 6

def mime_type
  @mime_type
end

Instance Method Details

#control_groupObject



24
25
26
# File 'lib/fedora/datastream.rb', line 24

def control_group
  @attributes[:controlGroup]
end

#control_group=(cg) ⇒ Object



27
28
29
# File 'lib/fedora/datastream.rb', line 27

def control_group=(cg)
  @attributes[:controlGroup]=cg
end

#dsidObject



31
32
33
34
35
36
37
# File 'lib/fedora/datastream.rb', line 31

def dsid
  if attributes.has_key?(:dsid) 
    attributes[:dsid]
  else
    attributes[:dsID]
  end
end

#labelObject



39
40
41
# File 'lib/fedora/datastream.rb', line 39

def label
  @attributes[:dsLabel]
end

#label=(new_label) ⇒ Object



43
44
45
# File 'lib/fedora/datastream.rb', line 43

def label=(new_label)
  @attributes[:dsLabel] = new_label
end

#pidObject



20
21
22
# File 'lib/fedora/datastream.rb', line 20

def pid
  attributes[:pid]
end

#uriObject



48
49
50
# File 'lib/fedora/datastream.rb', line 48

def uri
  "fedora:info/#{pid}/datastreams/#{dsid}"
end

#urlString

Returns url of the datastream in Fedora, without the repository userinfo.

Returns:

  • (String)

    url of the datastream in Fedora, without the repository userinfo



53
54
55
# File 'lib/fedora/datastream.rb', line 53

def url
  return "#{Fedora::Repository.instance.base_url}/objects/#{pid}/datastreams/#{dsid}"
end