Class: Stupidedi::Schema::Generation::ElementGenerator

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/stupidedi/schema/generation/element_generator.rb

Overview

Generates element_defs.rb for a release: every simple and composite element definition. ID elements with code lists emit a CodeList; control /separator elements (e.g. I15, I65) that carry no x12_type are emitted with the Separator type so #separator? is true.

Constant Summary collapse

TYPE_MAPPING =
{
  "AN" => :AN,
  "ID" => :ID,
  "DT" => :DT,
  "TM" => :TM,
  "R"  => :R,
  "N0" => :Nn,
  "N1" => :Nn,
  "N2" => :Nn,
  "N4" => :Nn,
  "N6" => :Nn,
  "N"  => :Nn,
  "B"  => :AN # Binary as AN
}.freeze

Instance Method Summary collapse

Methods included from Support

#namespace, #namespace_path

Constructor Details

#initialize(release, namespace: "Edi") ⇒ ElementGenerator

Returns a new instance of ElementGenerator.



28
29
30
31
# File 'lib/stupidedi/schema/generation/element_generator.rb', line 28

def initialize(release, namespace: "Edi")
  @release = release
  @namespace = namespace
end

Instance Method Details

#generateObject



33
34
35
36
# File 'lib/stupidedi/schema/generation/element_generator.rb', line 33

def generate
  validate_release!
  build_ruby_content
end

#output_pathObject



38
39
40
# File 'lib/stupidedi/schema/generation/element_generator.rb', line 38

def output_path
  "#{namespace_path}/#{underscore(version_module)}/element_defs.rb"
end