Class: Ddr::Models::Structures::File
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Models::Structures::File
- Defined in:
- lib/ddr/models/structures/file.rb
Overview
Wraps a Nokogiri (XML) ‘file’ node
Class Method Summary collapse
Instance Method Summary collapse
- #effective_use ⇒ Object
- #files ⇒ Object
- #flocats ⇒ Object
- #id ⇒ Object
- #repo_ids ⇒ Object
- #use ⇒ Object
Class Method Details
.build(args) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ddr/models/structures/file.rb', line 40 def self.build(args) node = Nokogiri::XML::Node.new('file', args[:document]) node['ID'] = args[:id] if args[:id] node['USE'] = args[:use] if args[:use] node end |
.find(structure, fileid) ⇒ Object
47 48 49 |
# File 'lib/ddr/models/structures/file.rb', line 47 def self.find(structure, fileid) structure.files[fileid] end |
Instance Method Details
#effective_use ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ddr/models/structures/file.rb', line 23 def effective_use if use use else case parent.name when "file" File.new(parent).effective_use when "fileGrp" FileGrp.new(parent).effective_use end end end |
#files ⇒ Object
15 16 17 |
# File 'lib/ddr/models/structures/file.rb', line 15 def files xpath('xmlns:file').map { |node| File.new(node) } end |
#flocats ⇒ Object
19 20 21 |
# File 'lib/ddr/models/structures/file.rb', line 19 def flocats xpath('xmlns:FLocat').map { |node| FLocat.new(node) } end |
#id ⇒ Object
7 8 9 |
# File 'lib/ddr/models/structures/file.rb', line 7 def id self['ID'] end |
#repo_ids ⇒ Object
36 37 38 |
# File 'lib/ddr/models/structures/file.rb', line 36 def repo_ids flocats.map(&:repo_id) end |
#use ⇒ Object
11 12 13 |
# File 'lib/ddr/models/structures/file.rb', line 11 def use self['USE'] end |