Class EDI::Dir::Directory
In: lib/edi4r/standards.rb
Parent: Object

A Directory object is currently a set of hashes representing all the entries for data elements, composites, segments, and messages.

Methods

Public Class methods

Tells if caching is currently activated (returns a boolean)

As long as we employ plain CSV files to store directories, a Directory can become quite memory-consuming. Therefore Directorys are cached after creation, so that they need to be created and maintained only once when there areeseveral messages of the same type in an interchange.

Turns off this caching mechanism, saving memory but costing time.

Turns on caching (default setting), saving time but costing memory.

Creates (and caches) a new directory. Returns reference to existing directory when already in cache.

std:The syntax standard key. Currently supported:
  • ‘E’ (EDIFACT),
  • ‘I’ (SAP IDOC)
params:A hash of parameters that uniquely identify the selected dir. Hash parameters use following alternative key sets:
ISO9735::d0002, :d0076 (default: "", nil)
UN/TDID::d0065, :d0052, :d0054, :d0051, :d0057; :is_iedi
SAP IDOC::IDOCTYPE, :SAPTYPE, :EXTENSION (see EDI_DC fields)

UN/TDID: Elements of S009 or S320 are used:

d0065:Message type like "INVOIC"
d0052:Message version number, like "90" or "D"
d0054:Message release number, like "1" or "03A"
d0051:Controlling agency, like "UN" or "EN"
d0057:Association assigned code (optional), like "EAN008"

Interactive EDI (only limited supported so far):

is_iedi:Flag, true or false. Assumed false if missing.

Releases memory by flushing the cache. Needed primarily for unit tests, where many if not all available diagrams are created.

Helper method: Determine path of requested csv file

Will be generalized to a lookup scheme!

Helper method: Derive path fragments of CSV files from parameters

Public Instance methods

Returns CSV line for CDE called name.

Returns a sorted list of names of available CDE

Returns CSV line for DE called name. If name is a Regexp, returns the first match or nil.

Returns a sorted list of names of available DE

Iterates over each branch (message), composite, data element, or segment found (hence: BCDS) that is matched by id.

id is a string. The object type requested by this string is not obvious. This method determines it through a naming convention. See source for details.

Fails with EDI::EDILookupError when nothing found.

Returns CSV line of top branch for message called name.

Returns a sorted list of names of available messages

Returns CSV line for segment called name. If name is a Regexp, returns the first match or nil.

Returns a sorted list of names of available segments

[Validate]