Class: Eddy::Build::LoopBuilder
- Inherits:
-
Object
- Object
- Eddy::Build::LoopBuilder
- Defined in:
- lib/eddy/build/loop_builder.rb
Overview
Generate Ruby code from JSON/YAML EDI definitions.
Instance Attribute Summary collapse
-
#folder ⇒ String
(nil).
- #summary ⇒ Eddy::Schema::LoopSummary
-
#t_set_id ⇒ String
Namespace the Loop is within.
Class Method Summary collapse
- .add_ideration(summary, t_set_id) ⇒ String
- .from_summary(summary, **kwargs) ⇒ Eddy::Build::LoopBuilder
Instance Method Summary collapse
- #components(t_set_id) ⇒ String
- #ginny_class ⇒ Ginny::Class
- #initialize(folder: nil, t_set_id: "") ⇒ void constructor
Constructor Details
#initialize(folder: nil, t_set_id: "") ⇒ void
19 20 21 22 |
# File 'lib/eddy/build/loop_builder.rb', line 19 def initialize(folder: nil, t_set_id: "") self.folder = folder self.t_set_id = t_set_id end |
Instance Attribute Details
#folder ⇒ String
11 12 13 |
# File 'lib/eddy/build/loop_builder.rb', line 11 def folder @folder end |
#summary ⇒ Eddy::Schema::LoopSummary
9 10 11 |
# File 'lib/eddy/build/loop_builder.rb', line 9 def summary @summary end |
#t_set_id ⇒ String
Namespace the Loop is within.
14 15 16 |
# File 'lib/eddy/build/loop_builder.rb', line 14 def t_set_id @t_set_id end |
Class Method Details
.add_ideration(summary, t_set_id) ⇒ String
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/eddy/build/loop_builder.rb', line 74 def self.add_ideration(summary, t_set_id) yield_params = [] summary.components.each do |comp| case comp when Eddy::Schema::SegmentSummary yield_params << "# @yieldparam [Eddy::Segments::#{comp.id.upcase}] #{comp.id.downcase}" when Eddy::Schema::LoopSummary yield_params << "# @yieldparam [Eddy::TransactionSets::#{t_set_id}::Loops::#{comp.loop_id.upcase}] l_#{comp.loop_id.downcase}" end end return " # @!method add_iteration(&block)\n \#{yield_params.join(\"\\n\")}\n # @return [void]\n YARD\nend\n".strip |
.from_summary(summary, **kwargs) ⇒ Eddy::Build::LoopBuilder
27 28 29 30 31 |
# File 'lib/eddy/build/loop_builder.rb', line 27 def self.from_summary(summary, **kwargs) lb = Eddy::Build::LoopBuilder.new(**kwargs) lb.summary = summary return lb end |
Instance Method Details
#components(t_set_id) ⇒ String
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/eddy/build/loop_builder.rb', line 58 def components(t_set_id) comps = [] self.summary.components.each do |comp| case comp when Eddy::Schema::SegmentSummary comps << " Eddy::Segments::#{comp.id.upcase}," when Eddy::Schema::LoopSummary comps << " Eddy::TransactionSets::#{t_set_id}::Loops::#{comp.loop_id.upcase}," end end return comps.join("\n ") end |
#ginny_class ⇒ Ginny::Class
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/eddy/build/loop_builder.rb', line 34 def ginny_class() return Ginny::Class.create({ classify_name: false, parent: "Eddy::Loop::Base", name: self.summary.loop_id, description: summary.doc_comment(header: true), body: " # @param store [Eddy::Data::Store]\n # @return [void]\n def initialize(store)\n super(store)\n @repeat = \#{self.summary.repeat}\n @components = [\n \#{self.components(self.t_set_id)}\n ]\n end\n\n \#{self.class.add_ideration(self.summary, self.t_set_id)}\n STR\n })\nend\n".strip, |