class Eancom::Factory
Attributes
config[R]
definition[R]
document[R]
Public Class Methods
new(json:)
click to toggle source
# File lib/eancom/factory.rb, line 8 def initialize(json:) @config = JSON.parse(json, object_class: OpenStruct) @document = Eancom::Edifact::Document.new end
Public Instance Methods
build()
click to toggle source
# File lib/eancom/factory.rb, line 13 def build @definition = Eancom.find_definition(name: name, type: type) @definition.run(document: document, config: config) @document end
Private Instance Methods
header()
click to toggle source
# File lib/eancom/factory.rb, line 30 def header config.header end
name()
click to toggle source
# File lib/eancom/factory.rb, line 34 def name header.message_version_number + header.message_release_number end
type()
click to toggle source
# File lib/eancom/factory.rb, line 21 def type type = header.message_type.downcase.to_sym if Eancom::FILE_TYPES.include?(type) type else raise Eancom::Error.new("EANCOM FILE TYPE NOT VALID!") end end