Class: Ddr::Structures::StructMap
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Structures::StructMap
- Defined in:
- lib/ddr/structures/struct_map.rb
Overview
Wraps a Nokogiri (XML) ‘structMap’ node
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(args) ⇒ Object
31 32 33 34 35 36 37 |
# 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 |
Instance Method Details
#dereferenced_hash ⇒ Object
23 24 25 26 27 28 29 |
# 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 ⇒ Object
19 20 21 |
# File 'lib/ddr/structures/struct_map.rb', line 19 def divs xpath('xmlns:div').map { |node| Div.new(node) } end |
#id ⇒ Object
7 8 9 |
# File 'lib/ddr/structures/struct_map.rb', line 7 def id self['ID'] end |
#label ⇒ Object
11 12 13 |
# File 'lib/ddr/structures/struct_map.rb', line 11 def label self['LABEL'] end |
#type ⇒ Object
15 16 17 |
# File 'lib/ddr/structures/struct_map.rb', line 15 def type self['TYPE'] end |