Class: Hpricot::XMLDecl
- Defined in:
- lib/hpricot/tag.rb,
lib/hpricot/modules.rb,
lib/hpricot/modules.rb
Defined Under Namespace
Modules: Trav
Constant Summary
Constants included from Hpricot
AttrCore, AttrEvents, AttrFocus, AttrHAlign, AttrI18n, AttrVAlign, Attrs, ElementContent, ElementExclusions, ElementInclusions, FORM_TAGS, NamedCharacters, NamedCharactersPattern, OmittedAttrName, PREDEFINED, PREDEFINED_U, SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from BaseEle
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version, encoding, standalone) ⇒ XMLDecl
constructor
A new instance of XMLDecl.
- #output(out, opts = {}) ⇒ Object
- #pathname ⇒ Object
Methods included from Leaf::Trav
#traverse_all_element, #traverse_some_element, #traverse_text_internal
Methods included from Traverse
#after, #at, #before, #bogusetag?, #children_of_type, #clean_path, #comment?, #css_path, #doc?, #doctype?, #elem?, filter, #following, #get_subnode, #html, #index, #inner_html=, #inner_text, #make, #next, #node_position, #nodes_at, #position, #preceding, #previous, #procins?, #search, #swap, #text?, #to_html, #to_original_html, #to_plain_text, #traverse_element, #traverse_text, #xmldecl?, #xpath
Methods included from Leaf
Methods included from Hpricot
XML, build, build_node, make, scan, uxs, xchr, xs
Methods inherited from BaseEle
alterable, #altered!, #html_quote, #if_output
Constructor Details
#initialize(version, encoding, standalone) ⇒ XMLDecl
Returns a new instance of XMLDecl.
169 170 171 |
# File 'lib/hpricot/tag.rb', line 169 def initialize(version, encoding, standalone) @version, @encoding, @standalone = version, encoding, standalone end |
Class Method Details
.parse(attrs, raw_string) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/hpricot/parse.rb', line 249 def XMLDecl.parse(attrs, raw_string) attrs ||= {} version = attrs['version'] encoding = attrs['encoding'] case attrs['standalone'] when 'yes' standalone = true when 'no' standalone = false else standalone = nil end result = XMLDecl.new(version, encoding, standalone) result.raw_string = raw_string result end |
Instance Method Details
#output(out, opts = {}) ⇒ Object
174 175 176 177 178 179 180 181 182 |
# File 'lib/hpricot/tag.rb', line 174 def output(out, opts = {}) out << if_output(opts) do "<?xml version=\"#{@version}\"" + (@encoding ? " encoding=\"#{encoding}\"" : "") + (@standalone != nil ? " standalone=\"#{standalone ? 'yes' : 'no'}\"" : "") + "?>" end end |
#pathname ⇒ Object
173 |
# File 'lib/hpricot/tag.rb', line 173 def pathname; "xmldecl()" end |