class OFX::Data::Serialization::Document::SGML
Attributes
registry[R]
Public Class Methods
new(registry)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 17 def initialize(registry) @registry = registry end
register_with(registry)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 10 def self.register_with(registry) serializer = new(registry) registry.register(serializer.registry_entry) end
Public Instance Methods
default_registry_entry_args()
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 21 def default_registry_entry_args [:document, nil] end
registry_entry()
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 25 def registry_entry Registry::Entry.new(self, *default_registry_entry_args) end
serialize(document, builder)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 29 def serialize(document, builder) write_headers(builder, document.declaration) builder.OFX do |builder| serialize_object(document.message_sets, builder) end end
Private Instance Methods
charset(declaration)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 68 def charset(declaration) case Encoding.find(declaration.encoding) when Encoding::UTF_8 "NONE" when Encoding::Windows_1252 "1252" when Encoding::ISO_8859_1 "ISO-8859-1" else raise ArgumentError, "Declaration encoding (#{declaration.encoding}) is not one of (or equivalent to) UTF-8, ISO-8859-1, or Windows-1252" end end
encoding(declaration)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 59 def encoding(declaration) case Encoding.find(declaration.encoding) when Encoding::UTF_8 "UTF-8" else "USASCII" end end
write_header(builder, name, value)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 55 def write_header(builder, name, value) builder << "#{name}:#{value}\r\n" end
write_headers(builder, declaration)
click to toggle source
# File lib/ofx/data/serialization/document/sgml.rb, line 38 def write_headers(builder, declaration) { OFXHEADER: declaration.ofxheader, DATA: "OFXSGML", VERSION: declaration.version, SECURITY: declaration.security, ENCODING: encoding(declaration), CHARSET: charset(declaration), COMPRESSION: "NONE", OLDFILEUID: declaration.oldfileuid, NEWFILEUID: declaration.newfileuid }.each do |name, value| write_header(builder, name, value) end builder << "\r\n" end