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 12"UTF-8" -
DEFAULT_STANDALONE =
# File 'lib/rexml/xmldecl.rb', line 13"no" -
DEFAULT_VERSION =
# File 'lib/rexml/xmldecl.rb', line 11"1.0" -
START =
# File 'lib/rexml/xmldecl.rb', line 14"<?xml" -
STOP =
# File 'lib/rexml/xmldecl.rb', line 15"?>"
Class Method Summary
Instance Attribute Summary
- #encoding=(enc) writeonly
-
#stand_alone?
readonly
Alias for #standalone.
- #standalone (also: #stand_alone?) rw
- #version rw
- #writeencoding readonly
- #writethis readonly
Encoding - Included
| #encoding | ID ---> |
| #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 20
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 @writethis = version.writethis else super() @version = version self.encoding = encoding @standalone = standalone end @version = DEFAULT_VERSION if @version.nil? end
Instance Attribute Details
#encoding=(enc) (writeonly)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 76
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 73
alias :stand_alone? :standalone
#standalone (rw) Also known as: #stand_alone?
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 17
attr_accessor :version, :standalone
#version (rw)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 17
attr_accessor :version, :standalone
#writeencoding (readonly)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 18
attr_reader :writeencoding, :writethis
#writethis (readonly)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 18
attr_reader :writeencoding, :writethis
Instance Method Details
#==(other)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 56
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 39
def clone XMLDecl.new(self) end
#content(enc) (private)
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 111
def content(enc) context = nil context = parent.context if parent if context and context[:prologue_quote] == :quote quote = "\"" else quote = "'" end rv = "version=#{quote}#{@version}#{quote}" if @writeencoding or enc !~ /\Autf-8\z/i rv << " encoding=#{quote}#{enc}#{quote}" end if @standalone rv << " standalone=#{quote}#{@standalone}#{quote}" end rv end
#dowrite
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 102
def dowrite @writethis = true end
#inspect
[ GitHub ]#node_type
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 69
def node_type :xmldecl end
#nowrite
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 98
def nowrite @writethis = false end
#old_enc=
[ GitHub ]# File 'lib/rexml/xmldecl.rb', line 74
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 63
def xmldecl version, encoding, standalone @version = version self.encoding = encoding @standalone = standalone end