Class: CXML::Document
- Inherits:
-
DocumentNode
- Object
- DocumentNode
- CXML::Document
- Defined in:
- lib/cxml/document.rb
Instance Attribute Summary
Attributes inherited from DocumentNode
Instance Method Summary collapse
- #from_xml(xml_string) ⇒ Object
- #initialize_timestamp(value) ⇒ Object
-
#message? ⇒ Boolean
Check if document is a message.
- #render ⇒ Object
-
#request? ⇒ Boolean
Check if document is request.
-
#response? ⇒ Boolean
Check if document is a response.
- #timestamp ⇒ Object
- #version ⇒ Object
Methods inherited from DocumentNode
accessible_attributes, accessible_nodes, attributes, #initialize, nodes, #render_nodes, #serializable_hash
Constructor Details
This class inherits a constructor from CXML::DocumentNode
Instance Method Details
#from_xml(xml_string) ⇒ Object
32 33 34 35 |
# File 'lib/cxml/document.rb', line 32 def from_xml(xml_string) initialize(Parser.new.parse(xml_string)) self end |
#initialize_timestamp(value) ⇒ Object
20 21 22 |
# File 'lib/cxml/document.rb', line 20 def (value) = Time.parse(value) end |
#message? ⇒ Boolean
Check if document is a message
51 52 53 |
# File 'lib/cxml/document.rb', line 51 def !.nil? end |
#render ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cxml/document.rb', line 55 def render node = CXML.builder node.doc.create_internal_subset( 'cXML', nil, "http://xml.cxml.org/schemas/cXML/#{version}/cXML.dtd" ) node.cXML(node_attributes) do |doc| header&.render(doc) request&.render(doc) response&.render(doc) &.render(doc) end node end |
#request? ⇒ Boolean
Check if document is request
39 40 41 |
# File 'lib/cxml/document.rb', line 39 def request? !request.nil? end |
#response? ⇒ Boolean
Check if document is a response
45 46 47 |
# File 'lib/cxml/document.rb', line 45 def response? !response.nil? end |
#timestamp ⇒ Object
24 25 26 |
# File 'lib/cxml/document.rb', line 24 def ||= Time.now.utc end |
#version ⇒ Object
28 29 30 |
# File 'lib/cxml/document.rb', line 28 def version @version ||= '1.2.037' end |