class Ddr::Structures::StructMap

Wraps a Nokogiri (XML) 'structMap' node

Public Class Methods

build(args) click to toggle source
# File lib/ddr/structures/struct_map.rb, line 31
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

Public Instance Methods

dereferenced_hash() click to toggle source
# File lib/ddr/structures/struct_map.rb, line 23
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
divs() click to toggle source
# File lib/ddr/structures/struct_map.rb, line 19
def divs
  xpath('xmlns:div').map { |node| Div.new(node) }
end
id() click to toggle source
# File lib/ddr/structures/struct_map.rb, line 7
def id
  self['ID']
end
label() click to toggle source
# File lib/ddr/structures/struct_map.rb, line 11
def label
  self['LABEL']
end
type() click to toggle source
# File lib/ddr/structures/struct_map.rb, line 15
def type
  self['TYPE']
end