Class: Libis::Tools::MetsFile::Div

Inherits:
Object
  • Object
show all
Includes:
MetsObject, ThreadSafe
Defined in:
lib/libis/tools/mets_objects.rb

Overview

Container class for creating a division in the METS.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ThreadSafe

#mutex

Methods included from MetsObject

#id, #initialize, #set_from_hash, #set_id, #to_s

Instance Attribute Details

#labelObject

Returns the value of attribute label.



303
304
305
# File 'lib/libis/tools/mets_objects.rb', line 303

def label
  @label
end

Instance Method Details

#<<(obj) ⇒ Object

Add an item (File or Libis::Tools::MetsFile::Div) to the current division



330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/libis/tools/mets_objects.rb', line 330

def <<(obj)
  self.mutex.synchronize do
    case obj
      when File
        files << obj
      when Div
        divs << obj
      else
        raise RuntimeError, "Child object type not supported: #{obj.class}"
    end
  end
end

#childrenObject

All items stored in the current division



311
312
313
# File 'lib/libis/tools/mets_objects.rb', line 311

def children
  files + divs
end

#divsObject

All division items stored in the current division



323
324
325
326
327
# File 'lib/libis/tools/mets_objects.rb', line 323

def divs
  self.mutex.synchronize do
    @divs ||= Array.new
  end
end

#filesObject

All file items stored in the current division



316
317
318
319
320
# File 'lib/libis/tools/mets_objects.rb', line 316

def files
  self.mutex.synchronize do
    @files ||= Array.new
  end
end

#xml_idObject

The id that will be used in the XML file to reference this division.



306
307
308
# File 'lib/libis/tools/mets_objects.rb', line 306

def xml_id
  "div-#{@id}"
end