Class: Oga::XML::Doctype
- Inherits:
-
Object
- Object
- Oga::XML::Doctype
- Defined in:
- lib/oga/xml/doctype.rb
Overview
Class used for storing information about Doctypes.
Instance Attribute Summary collapse
-
#inline_rules ⇒ String
The inline doctype rules.
-
#name ⇒ String
The name of the doctype (e.g. "HTML").
-
#public_id ⇒ String
The public ID of the doctype.
-
#system_id ⇒ String
The system ID of the doctype.
-
#type ⇒ String
The type of the doctype (e.g. "PUBLIC").
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Doctype
constructor
A new instance of Doctype.
-
#inspect ⇒ String
Inspects the doctype.
-
#to_xml ⇒ String
Converts the doctype back to XML.
Constructor Details
#initialize(options = {}) ⇒ Doctype
Returns a new instance of Doctype.
38 39 40 41 42 43 44 |
# File 'lib/oga/xml/doctype.rb', line 38 def initialize( = {}) @name = [:name] @type = [:type] @public_id = [:public_id] @system_id = [:system_id] @inline_rules = [:inline_rules] end |
Instance Attribute Details
#inline_rules ⇒ String
The inline doctype rules.
25 26 27 |
# File 'lib/oga/xml/doctype.rb', line 25 def inline_rules @inline_rules end |
#name ⇒ String
The name of the doctype (e.g. "HTML").
9 10 11 |
# File 'lib/oga/xml/doctype.rb', line 9 def name @name end |
#public_id ⇒ String
The public ID of the doctype.
17 18 19 |
# File 'lib/oga/xml/doctype.rb', line 17 def public_id @public_id end |
#system_id ⇒ String
The system ID of the doctype.
21 22 23 |
# File 'lib/oga/xml/doctype.rb', line 21 def system_id @system_id end |
#type ⇒ String
The type of the doctype (e.g. "PUBLIC").
13 14 15 |
# File 'lib/oga/xml/doctype.rb', line 13 def type @type end |
Instance Method Details
#inspect ⇒ String
Inspects the doctype.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/oga/xml/doctype.rb', line 67 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 |
#to_xml ⇒ String
Converts the doctype back to XML.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/oga/xml/doctype.rb', line 51 def to_xml segments = "<!DOCTYPE #{name}" segments << " #{type}" if type segments << %Q{ "#{public_id}"} if public_id segments << %Q{ "#{system_id}"} if system_id segments << " [#{inline_rules}]" if inline_rules segments + '>' end |