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.



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

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.



13
14
15
# File 'lib/moxml/adapter/libxml.rb', line 13

def external_id
  @external_id
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/moxml/adapter/libxml.rb', line 13

def name
  @name
end

#native_docObject (readonly)

Returns the value of attribute native_doc.



12
13
14
# File 'lib/moxml/adapter/libxml.rb', line 12

def native_doc
  @native_doc
end

#system_idObject

Returns the value of attribute system_id.



13
14
15
# File 'lib/moxml/adapter/libxml.rb', line 13

def system_id
  @system_id
end

Instance Method Details

#nativeObject

Provide native method to match adapter pattern



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

def native
  @native_doc
end

#to_xmlObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/moxml/adapter/libxml.rb', line 27

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