Sha256: 916a2f4bfa1cb104953c69800a98e534c8ac88b9bc707da7b9abda9b9780a07b

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

require 'ox'

module Ox
  class Document
    def root
      children.first
    end
  end

  class Element
    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

    alias children nodes
    alias tag_name name

    def unparsed_children
      @unparsed_children ||= children.dup
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
goldendocx-0.3.0 lib/extensions/ox_extensions.rb
goldendocx-0.2.3 lib/extensions/ox_extensions.rb