Class: Ox::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/ox_extensions.rb

Instance Method Summary collapse

Instance Method Details

#<<(node) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/extensions/ox_extensions.rb', line 13

def <<(node)
  # FIXME: Add this line to transform element implicitly
  node = node.public_send(:to_element) if node.respond_to?(:to_element)

  raise 'argument to << must be a String or Ox::Node.' unless node.is_a?(String) || node.is_a?(Node)

  @nodes = [] if !instance_variable_defined?(:@nodes) || @nodes.nil?
  @nodes << node
  self
end

#attributes_hashObject



31
32
33
# File 'lib/extensions/ox_extensions.rb', line 31

def attributes_hash
  attributes.with_indifferent_access.reject { |k, _| k.to_s.start_with?('xmlns') || k.to_s == 'mc:Ignorable' }
end

#unparsed_childrenObject



27
28
29
# File 'lib/extensions/ox_extensions.rb', line 27

def unparsed_children
  @unparsed_children ||= children.dup
end