Class: Moxml::Adapter::Libxml::DoctypeWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/adapter/libxml.rb

Overview

Wrapper class to store DOCTYPE information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc, name, external_id, system_id) ⇒ DoctypeWrapper

Returns a new instance of DoctypeWrapper.



21
22
23
24
25
26
# File 'lib/moxml/adapter/libxml.rb', line 21

def initialize(doc, name, external_id, system_id)
  @native_doc = doc
  @name = name
  @external_id = external_id
  @system_id = system_id
end

Instance Attribute Details

#external_idObject

Returns the value of attribute external_id.



19
20
21
# File 'lib/moxml/adapter/libxml.rb', line 19

def external_id
  @external_id
end

#nameObject

Returns the value of attribute name.



19
20
21
# File 'lib/moxml/adapter/libxml.rb', line 19

def name
  @name
end

#native_docObject (readonly)

Returns the value of attribute native_doc.



18
19
20
# File 'lib/moxml/adapter/libxml.rb', line 18

def native_doc
  @native_doc
end

#system_idObject

Returns the value of attribute system_id.



19
20
21
# File 'lib/moxml/adapter/libxml.rb', line 19

def system_id
  @system_id
end

Instance Method Details

#nativeObject

Provide native method to match adapter pattern



29
30
31
# File 'lib/moxml/adapter/libxml.rb', line 29

def native
  @native_doc
end

#to_xmlObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/moxml/adapter/libxml.rb', line 33

def to_xml
  output = "<!DOCTYPE #{@name}"
  if @external_id && !@external_id.empty?
    output << " PUBLIC \"#{@external_id}\""
    output << " \"#{@system_id}\"" if @system_id
  elsif @system_id && !@system_id.empty?
    output << " SYSTEM \"#{@system_id}\""
  end
  output << ">"
  output
end