Sha256: e43ab8739ae29adf8b715a8fb456281ad4c5c795e26a74a17bc98854a6848958

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module Nokogiri
  module XML
    class Node
      ###
      # Save options for serializing nodes
      class SaveOptions
        # Format serialized xml
        FORMAT          = 1
        # Do not include delcarations
        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

        # 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

3 entries across 3 versions & 2 rubygems

Version Path
nokogiri-1.5.0.beta.4 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.0.beta.4-java lib/nokogiri/xml/node/save_options.rb
nokogiri-backupify-1.5.0.beta.4 lib/nokogiri/xml/node/save_options.rb