Class: Libis::Tools::MetsFile::File

Inherits:
Object
  • Object
show all
Includes:
IdContainer
Defined in:
lib/libis/tools/mets_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IdContainer

#id, #set_from_hash, #to_s

Instance Attribute Details

#dc_recordObject

Returns the value of attribute dc_record.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def dc_record
  @dc_record
end

#entity_typeObject

Returns the value of attribute entity_type.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def entity_type
  @entity_type
end

#labelObject

Returns the value of attribute label.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def label
  @label
end

#locationObject

Returns the value of attribute location.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def location
  @location
end

#mimetypeObject

Returns the value of attribute mimetype.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def mimetype
  @mimetype
end

#representationObject

Returns the value of attribute representation.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def representation
  @representation
end

#target_locationObject

Returns the value of attribute target_location.



69
70
71
# File 'lib/libis/tools/mets_file.rb', line 69

def target_location
  @target_location
end

Instance Method Details

#add_manifestation(file) ⇒ Object



91
92
93
94
# File 'lib/libis/tools/mets_file.rb', line 91

def add_manifestation(file)
  manifestations << file
  file.master = self
end

#amdObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/libis/tools/mets_file.rb', line 111

def amd
  dnx = {}
  tech_data = []
  data = {
      label: label,
      fileMIMEType: mimetype,
      fileOriginalName: orig_name,
      fileOriginalPath: orig_path,
      FileEntityType: entity_type,
      # fileSizeBytes: size,
  }.cleanup
  tech_data << TechGeneralFile.new(data) unless data.empty?
  # data = {
  #     fixityType: fixity_type,
  #     fixityValue: fixity_value,
  # }.cleanup
  # tech_data << TechFixity.new(data) unless data.empty?
  dnx[:tech] = tech_data unless tech_data.empty?
  dnx
end

#group_idObject



75
76
77
# File 'lib/libis/tools/mets_file.rb', line 75

def group_id
  "grp#{master.id rescue id}"
end

#manifestationsObject



87
88
89
# File 'lib/libis/tools/mets_file.rb', line 87

def manifestations
  @manifestations ||= Array.new
end

#masterObject



79
80
81
# File 'lib/libis/tools/mets_file.rb', line 79

def master
  @master ||= nil
end

#master=(file) ⇒ Object



83
84
85
# File 'lib/libis/tools/mets_file.rb', line 83

def master=(file)
  @master = file
end

#orig_nameObject



96
97
98
# File 'lib/libis/tools/mets_file.rb', line 96

def orig_name
  ::File.basename(location)
end

#orig_pathObject



100
101
102
# File 'lib/libis/tools/mets_file.rb', line 100

def orig_path
  ::File.dirname(location)
end

#targetObject



104
105
106
107
108
109
# File 'lib/libis/tools/mets_file.rb', line 104

def target
  if target_location.nil?
    return "#{xml_id}#{::File.extname(location)}"
  end
  target_location
end

#xml_idObject



71
72
73
# File 'lib/libis/tools/mets_file.rb', line 71

def xml_id
  "fid#{id}"
end