Class: REXML::XMLDecl
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Child
|
|
Instance Chain:
|
|
Inherits: |
REXML::Child
|
Defined in: | lib/rexml/xmldecl.rb |
Overview
NEEDS DOCUMENTATION
Constant Summary
-
DEFAULT_ENCODING =
# File 'lib/rexml/xmldecl.rb', line 11"UTF-8"
-
DEFAULT_STANDALONE =
# File 'lib/rexml/xmldecl.rb', line 12"no"
-
DEFAULT_VERSION =
# File 'lib/rexml/xmldecl.rb', line 10"1.0"
-
START =
# File 'lib/rexml/xmldecl.rb', line 13'<\?xml'
-
STOP =
# File 'lib/rexml/xmldecl.rb', line 14'\?>'
Class Method Summary
-
.default
Only use this if you do not want the XML declaration to be written; this object is ignored by the XML writer.
- .new(version = DEFAULT_VERSION, encoding = nil, standalone = nil) ⇒ XMLDecl constructor
Child - Inherited
.new | Constructor. |
Instance Attribute Summary
- #standalone (also: #stand_alone?) rw
- #version rw
-
#stand_alone?
readonly
Alias for #standalone.
- #writeencoding readonly
- #writethis readonly
- #encoding=(enc) writeonly
Encoding - Included
#encoding | ID —> Encoding name. |
#encoding= |
Child - Inherited
#next_sibling | Alias for Node#next_sibling_node. |
#next_sibling= | Sets the next sibling of this child. |
#parent | The Parent of this object. |
#parent= | Sets the parent of this child to the supplied argument. |
#previous_sibling | Alias for Node#previous_sibling_node. |
#previous_sibling= | Sets the previous sibling of this child. |
Node - Included
Instance Method Summary
- #==(other)
- #clone
- #dowrite
- #inspect
- #node_type
- #nowrite
- #old_enc=
-
#write(writer, indent = -1,, transitive = false, ie_hack = false)
- indent
- #xmldecl(version, encoding, standalone)
- #content(enc) private
Encoding - Included
Child - Inherited
#bytes | This doesn't yet handle encodings. |
#document |
|
#remove | Removes this child from the parent. |
#replace_with | Replaces this object with another object. |
Node - Included
#each_recursive | Visit all subnodes of |
#find_first_recursive | Find (and return) first subnode (recursively) for which the block evaluates to true. |
#indent, | |
#index_in_parent | Returns the position that |
#next_sibling_node, #previous_sibling_node, | |
#to_s |
|
Constructor Details
.new(version = DEFAULT_VERSION, encoding = nil, standalone = nil) ⇒ XMLDecl
# File 'lib/rexml/xmldecl.rb', line 19
def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil) @writethis = true @writeencoding = !encoding.nil? if version.kind_of? XMLDecl super() @version = version.version self.encoding = version.encoding @writeencoding = version.writeencoding @standalone = version.standalone else super() @version = version self.encoding = encoding @standalone = standalone end @version = DEFAULT_VERSION if @version.nil? end
Class Method Details
.default
Only use this if you do not want the XML declaration to be written; this object is ignored by the XML writer. Otherwise, instantiate your own XMLDecl
and add it to the document.
Note that XML 1.1 documents must include an XML declaration
Instance Attribute Details
#encoding=(enc) (writeonly)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 74
def encoding=( enc ) if enc.nil? self.old_enc = "UTF-8" @writeencoding = false else self.old_enc = enc @writeencoding = true end self.dowrite end
#stand_alone? (readonly)
Alias for #standalone.
# File 'lib/rexml/xmldecl.rb', line 71
alias :stand_alone? :standalone
#standalone (rw) Also known as: #stand_alone?
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 16
attr_accessor :version, :standalone
#version (rw)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 16
attr_accessor :version, :standalone
#writeencoding (readonly)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 17
attr_reader :writeencoding, :writethis
#writethis (readonly)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 17
attr_reader :writeencoding, :writethis
Instance Method Details
#==(other)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 54
def ==( other ) other.kind_of?(XMLDecl) and other.version == @version and other.encoding == self.encoding and other.standalone == @standalone end
#clone
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 37
def clone XMLDecl.new(self) end
#content(enc) (private)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 109
def content(enc) rv = "version='#@version'" rv << " encoding='#{enc}'" if @writeencoding || enc !~ /\Autf-8\z/i rv << " standalone='#@standalone'" if @standalone rv end
#dowrite
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 100
def dowrite @writethis = true end
#inspect
[ GitHub ]#node_type
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 67
def node_type :xmldecl end
#nowrite
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 96
def nowrite @writethis = false end
#old_enc=
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 72
alias :old_enc= :encoding=
#write(writer, indent = -1,, transitive = false, ie_hack = false)
- indent
-
Ignored. There must be no whitespace before an XML declaration
- transitive
-
Ignored
- ie_hack
-
Ignored
#xmldecl(version, encoding, standalone)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 61
def xmldecl version, encoding, standalone @version = version self.encoding = encoding @standalone = standalone end