Sha256: fffcc0ec6600b0602641111dbc9e8326cd9c97bb5b35f11701fe41a6594047d4

Contents?: true

Size: 1.72 KB

Versions: 88

Compression:

Stored size: 1.72 KB

Contents

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/tenderlove/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

88 entries across 88 versions & 10 rubygems

Version Path
nokogiri-maglev--1.5.2 lib/nokogiri/xml/node/save_options.rb
nokogiri-maglev--1.5.4.20120815005250 lib/nokogiri/xml/node/save_options.rb
nokogiri-maglev--1.5.3 lib/nokogiri/xml/node/save_options.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xml/node/save_options.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xml/node/save_options.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xml/node/save_options.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc2 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc2-java lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc2-x86-mingw32 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc2-x86-mswin32-60 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc1-x86-mingw32 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc1 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc1-java lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.5.rc1-x86-mswin32-60 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.4-x86-mingw32 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.4 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.4-java lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.4-x86-mswin32-60 lib/nokogiri/xml/node/save_options.rb
nokogiri-1.5.4.rc3 lib/nokogiri/xml/node/save_options.rb