Sha256: 1cab8eb9de257b6b8ee15aae8f7f43bea3bcf3498e399f79ce62907fdbe27fa8

Contents?: true

Size: 829 Bytes

Versions: 43

Compression:

Stored size: 829 Bytes

Contents

module Ddr::Structures
  #
  # Wraps a Nokogiri (XML) 'structMap' node
  #
  class StructMap < SimpleDelegator

    def id
      self['ID']
    end

    def label
      self['LABEL']
    end

    def type
      self['TYPE']
    end

    def divs
      xpath('xmlns:div').map { |node| Div.new(node) }
    end

    def dereferenced_hash
      contents = []
      contents.concat(divs.map { |div| div.dereferenced_hash }) unless divs.empty?
      dh = { id: id, label: label, type: type }.compact
      dh[:contents] = contents unless contents.empty?
      dh
    end

    def self.build(args)
      node = Nokogiri::XML::Node.new('structMap', args[:document])
      node['ID'] = args[:id] if args[:id]
      node['LABEL'] = args[:label] if args[:label]
      node['TYPE'] = args[:type] if args[:type]
      node
    end

  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
ddr-core-1.17.0 lib/ddr/structures/struct_map.rb
ddr-core-1.16.0 lib/ddr/structures/struct_map.rb
ddr-core-1.15.0 lib/ddr/structures/struct_map.rb
ddr-core-1.14.0 lib/ddr/structures/struct_map.rb
ddr-core-1.13.2 lib/ddr/structures/struct_map.rb
ddr-core-1.13.1 lib/ddr/structures/struct_map.rb
ddr-core-1.13.0 lib/ddr/structures/struct_map.rb
ddr-core-1.12.2 lib/ddr/structures/struct_map.rb
ddr-core-1.12.1 lib/ddr/structures/struct_map.rb
ddr-core-1.12.0 lib/ddr/structures/struct_map.rb
ddr-core-1.11.0 lib/ddr/structures/struct_map.rb
ddr-core-1.10.0 lib/ddr/structures/struct_map.rb
ddr-core-1.9.0 lib/ddr/structures/struct_map.rb
ddr-core-1.8.0 lib/ddr/structures/struct_map.rb
ddr-core-1.7.0 lib/ddr/structures/struct_map.rb
ddr-core-1.6.6 lib/ddr/structures/struct_map.rb
ddr-core-1.6.5 lib/ddr/structures/struct_map.rb
ddr-core-1.6.4 lib/ddr/structures/struct_map.rb
ddr-core-1.6.3 lib/ddr/structures/struct_map.rb
ddr-core-1.6.2 lib/ddr/structures/struct_map.rb