Class EDI::E::Interchange
In: lib/edi4r/edifact.rb
lib/edi4r/edifact-rexml.rb
Parent: EDI::Interchange

Interchange: Class of the top-level objects of UN/EDIFACT data

Methods

add   inspect   is_iedi?   new   new_message   new_msggroup   output_mode=   parse   parse_xml   peek   peek_xml   to_din16557_4   to_s   to_xml   validate  

Attributes

charset  [R] 
groups_created  [R] 
messages_created  [R] 
show_una  [RW] 
una  [R] 

Public Class methods

Create an empty UN/EDIFACT interchange

Supported parameters (passed hash-style):

Essentials, should not be changed later

:charset :Sets S001.0001, default = ‘UNOB‘
:version :Sets S001.0002, default = 3
:i_edi :Interactive EDI mode, a boolean (UIB instead of UNB …), default = false

Optional parameters affecting to_s, with corresponding setters

:show_una :Adds UNA sement to output, default = true
:output_mode :See setter output_mode=(), default = :verbatim
:una_string :See class UNA for setters, default = nil

Optional UNB presets for your convenience, may be changed later

:sender :Presets DE S002/0004, default = nil
:recipient :Presets DE S003/0010, default = nil
:interchange_control_reference :Presets DE 0020, default = ‘1’
:application_reference :Presets DE 0026, default = nil
:interchange_agreement_id :Presets DE 0032, default = nil
:acknowledgment_request :Presets DE 0031, default = nil
:test_indicator :Presets DE 0035, default = nil

Notes

  • Date and time in S004 are set to the current values automatically.
  • Add or change any data element later. except those in S001.

Examples:

Reads EDIFACT data from given stream (default: $stdin), parses it and returns an Interchange object

Returns a REXML document that represents the interchange

xdoc:REXML document that contains the XML representation of a UN/EDIFACT interchange

Read maxlen bytes from $stdin (default) or from given stream (UN/EDIFACT data expected), and peek into first segment (UNB/UIB).

Returns an empty Interchange object with a properly header filled.

Intended use:

  Efficient routing by reading just UNB data: sender/recipient/ref/test

Read maxlen bytes from $stdin (default) or from given stream (UN/EDIFACT data expected), and peek into first segment (UNB/UIB).

Returns an empty Interchange object with a properly header filled.

Intended use:

  Efficient routing by reading just UNB data: sender/recipient/ref/test

Public Instance methods

Add either a MsgGroup or Message object to the interchange. Note: Don‘t mix both types!

UNZ/UIZ counter DE 0036 is automatically incremented.

Yields a readable, properly indented list of all contained objects, including the empty ones. This may be a very long string!

Returns true if this is an I-EDI interchange (Interactive EDI)

Derive an empty message from this interchange context. Parameters may be passed hash-like. See Message.new for details

Derive an empty message group from this interchange context. Parameters may be passed hash-like. See MsgGroup.new for details

This method modifies the behaviour of method to_s(): UN/EDIFACT interchanges and their components are turned into strings either "verbatim" (default) or in some more readable way. This method corresponds to a parameter with same name at creation time.

Valid values:

:linebreak :One-segment-per-line representation
:indented :Like :linebreak but with additional indentation (2 blanks per hierarchy level).
:verbatim :No linebreak (default), ISO compliant

Returns a REXML document that represents the interchange according to DIN 16557-4

Returns the string representation of the interchange.

Type conversion and escaping are provided. The UNA object is shown when show_una is set to true . See output_mode for modifiers.

Returns a REXML document that represents the interchange

Returns the number of warnings found, writes warnings to STDERR

[Validate]