Class: Oga::XML::Doctype

Inherits:
Node
  • Object
show all
Defined in:
lib/oga/xml/doctype.rb

Overview

Class used for storing information about Doctypes.

Instance Attribute Summary collapse

Attributes inherited from Node

#next, #node_set, #previous

Instance Method Summary collapse

Methods inherited from Node

#after, #before, #children, #children=, #each_ancestor, #html?, #next_element, #parent, #previous_element, #remove, #replace, #root_node, #xml?

Methods included from ToXML

#to_xml

Methods included from Traversal

#each_node

Constructor Details

#initialize(options = {}) ⇒ Doctype

Returns a new instance of Doctype

Examples:

dtd = Doctype.new(:name => 'html', :type => 'PUBLIC')

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :name (String)
  • :type (String)
  • :public_id (String)
  • :system_id (String)


34
35
36
37
38
39
40
# File 'lib/oga/xml/doctype.rb', line 34

def initialize(options = {})
  @name         = options[:name]
  @type         = options[:type]
  @public_id    = options[:public_id]
  @system_id    = options[:system_id]
  @inline_rules = options[:inline_rules]
end

Instance Attribute Details

#inline_rulesString

The inline doctype rules.

Returns:

  • (String)


23
24
25
# File 'lib/oga/xml/doctype.rb', line 23

def inline_rules
  @inline_rules
end

#nameString

The name of the doctype (e.g. “HTML”).

Returns:

  • (String)


7
8
9
# File 'lib/oga/xml/doctype.rb', line 7

def name
  @name
end

#public_idString

The public ID of the doctype.

Returns:

  • (String)


15
16
17
# File 'lib/oga/xml/doctype.rb', line 15

def public_id
  @public_id
end

#system_idString

The system ID of the doctype.

Returns:

  • (String)


19
20
21
# File 'lib/oga/xml/doctype.rb', line 19

def system_id
  @system_id
end

#typeString

The type of the doctype (e.g. “PUBLIC”).

Returns:

  • (String)


11
12
13
# File 'lib/oga/xml/doctype.rb', line 11

def type
  @type
end

Instance Method Details

#inspectString

Inspects the doctype.

Returns:

  • (String)


45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oga/xml/doctype.rb', line 45

def inspect
  segments = []

  [:name, :type, :public_id, :system_id, :inline_rules].each do |attr|
    value = send(attr)

    if value and !value.empty?
      segments << "#{attr}: #{value.inspect}"
    end
  end

  "Doctype(#{segments.join(' ')})"
end