Sha256: 209d94c47490aa5ddc212c5f906aed20059a30091f4572ef495b49d0413d482b
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require('time') module CXML class Document < DocumentNode accessible_attributes %i[ version payload_id xml_lang timestamp ] accessible_nodes %i[ header message request response ] def initialize_timestamp(value) @timestamp = Time.parse(value) end def timestamp @timestamp ||= Time.now.utc end def version @version ||= '1.2.037' end def from_xml(xml_string) initialize(Parser.new.parse(xml_string)) self end # Check if document is request # @return [Boolean] def request? !request.nil? end # Check if document is a response # @return [Boolean] def response? !response.nil? end # Check if document is a message # @return [Boolean] def message? !message.nil? end 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) message&.render(doc) end node end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cxml-ruby-0.2.1 | lib/cxml/document.rb |
cxml-ruby-0.2.0 | lib/cxml/document.rb |