Class: Hpricot::XMLDecl

Inherits:
BaseEle show all
Includes:
Leaf, Trav
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

ElementContent, ElementExclusions, ElementInclusions, NamedCharacters, NamedCharactersPattern, OmittedAttrName

Instance Attribute Summary

Attributes inherited from BaseEle

#parent, #raw_string

Class Method Summary collapse

Instance Method Summary collapse

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, #get_subnode, #inner_html, #inner_html=, #inner_text, #next_node, #node_position, #nodes_at, #position, #previous_node, #procins?, #search, #swap, #text?, #to_html, #to_original_html, #to_plain_text, #traverse_element, #traverse_text, #xmldecl?, #xpath

Methods included from Leaf

#pretty_print

Methods included from Hpricot

XML, build_node, make, scan

Methods inherited from BaseEle

alterable, #altered!, #html_quote, #if_output

Constructor Details

#initialize(version, encoding, standalone) ⇒ XMLDecl

Returns a new instance of XMLDecl.



157
158
159
# File 'lib/hpricot/tag.rb', line 157

def initialize(version, encoding, standalone)
  @version, @encoding, @standalone = version, encoding, standalone
end

Class Method Details

.parse(attrs, raw_string) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/hpricot/parse.rb', line 221

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



162
163
164
165
166
167
168
169
170
# File 'lib/hpricot/tag.rb', line 162

def output(out, opts = {})
  out <<
    if_output(opts) do
      "<?xml version=\"#{@version}\"" +
        (@encoding ? " encoding=\"#{encoding}\"" : "") +
        (@standalone != nil ? " standalone=\"#{standalone ? 'yes' : 'no'}\"" : "") +
        "?>"
    end
end

#pathnameObject



161
# File 'lib/hpricot/tag.rb', line 161

def pathname; "xmldecl()" end