class Ddr::Structures::Div

Wraps a Nokogiri (XML) 'div' node

Public Class Methods

build(args) click to toggle source
# File lib/ddr/structures/div.rb, line 53
def self.build(args)
  node = Nokogiri::XML::Node.new('div', args[:document])
  node['ID'] = args[:id] if args[:id]
  node['LABEL'] = args[:label] if args[:label]
  node['ORDER'] = args[:order] if args[:order]
  node['ORDERLABEL'] = args[:orderlabel] if args[:orderlabel]
  node['TYPE'] = args[:type] if args[:type]
  node
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/ddr/structures/div.rb, line 39
def <=>(other)
  order.to_i <=> other.order.to_i
end
dereferenced_hash() click to toggle source
# File lib/ddr/structures/div.rb, line 43
def dereferenced_hash
  contents = []
  contents.concat(divs.map { |div| div.dereferenced_hash }) unless divs.empty?
  contents.concat(fptrs.map { |fptr| fptr.dereferenced_hash }) unless fptrs.empty?
  contents.concat(mptrs.map { |mptr| mptr.dereferenced_hash }) unless mptrs.empty?
  dh = { id: id, label: label, order: order, orderlabel: orderlabel, type: type }.compact
  dh[:contents] = contents unless contents.empty?
  dh
end
divs() click to toggle source
# File lib/ddr/structures/div.rb, line 27
def divs
  xpath('xmlns:div').map { |node| Div.new(node) }
end
fptrs() click to toggle source
# File lib/ddr/structures/div.rb, line 31
def fptrs
  xpath('xmlns:fptr').map { |node| Fptr.new(node) }
end
id() click to toggle source
# File lib/ddr/structures/div.rb, line 7
def id
  self['ID']
end
label() click to toggle source
# File lib/ddr/structures/div.rb, line 11
def label
  self['LABEL']
end
mptrs() click to toggle source
# File lib/ddr/structures/div.rb, line 35
def mptrs
  xpath('xmlns:mptr').map { |node| Mptr.new(node) }
end
order() click to toggle source
# File lib/ddr/structures/div.rb, line 15
def order
  self['ORDER']
end
orderlabel() click to toggle source
# File lib/ddr/structures/div.rb, line 19
def orderlabel
  self['ORDERLABEL']
end
type() click to toggle source
# File lib/ddr/structures/div.rb, line 23
def type
  self['TYPE']
end