Sha256: 87903b8a21b1180a8b45fa208248db5e2b75b2b456e7cf454f852f89d230d68c

Contents?: true

Size: 1.76 KB

Versions: 152

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true
module Nokogiri
  module XML
    class Node
      ###
      # Save options for serializing nodes
      class SaveOptions
        # Format serialized xml
        FORMAT          = 1
        # Do not include declarations
        NO_DECLARATION  = 2
        # Do not include empty tags
        NO_EMPTY_TAGS   = 4
        # Do not save XHTML
        NO_XHTML        = 8
        # Save as XHTML
        AS_XHTML        = 16
        # Save as XML
        AS_XML          = 32
        # Save as HTML
        AS_HTML         = 64

        if Nokogiri.jruby?
          # Save builder created document
          AS_BUILDER    = 128
          # the default for XML documents
          DEFAULT_XML  = AS_XML # https://github.com/sparklemotion/nokogiri/issues/#issue/415
          # the default for HTML document
          DEFAULT_HTML = NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
        else
          # the default for XML documents
          DEFAULT_XML  = FORMAT | AS_XML
          # the default for HTML document
          DEFAULT_HTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
        end
        # the default for XHTML document
        DEFAULT_XHTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_XHTML

        # Integer representation of the SaveOptions
        attr_reader :options

        # Create a new SaveOptions object with +options+
        def initialize options = 0; @options = options; end

        constants.each do |constant|
          class_eval %{
            def #{constant.downcase}
              @options |= #{constant}
              self
            end

            def #{constant.downcase}?
              #{constant} & @options == #{constant}
            end
          }
        end

        alias :to_i :options
      end
    end
  end
end

Version data entries

152 entries across 146 versions & 5 rubygems

Version Path
nokogiri-backport-1.11.0 lib/nokogiri/xml/node/save_options.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-x86_64-linux lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-x86_64-darwin lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-x86-mingw32 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-x86-linux lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-x64-mingw32 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-java lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.4-arm64-darwin lib/nokogiri/xml/node/save_options.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xml/node/save_options.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/nokogiri-1.12.3-x86_64-linux/lib/nokogiri/xml/node/save_options.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/nokogiri-1.11.7-x86_64-linux/lib/nokogiri/xml/node/save_options.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/nokogiri-1.12.3-x86_64-linux/lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.3 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.3-x86_64-linux lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.3-x86_64-darwin lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.3-x86-mingw32 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.3-x86-linux lib/nokogiri/xml/node/save_options.rb
nokogiri-1.12.3-x64-mingw32 lib/nokogiri/xml/node/save_options.rb