Class: Eddy::Build::Loop::Repeat
- Inherits:
-
Object
- Object
- Eddy::Build::Loop::Repeat
- Defined in:
- lib/eddy/build/loop/repeat.rb
Overview
Generate Ruby code from JSON/YAML EDI definitions.
Instance Attribute Summary collapse
- #summary ⇒ Eddy::Summary::Loop
-
#t_set_id ⇒ String
Namespace the Loop is within.
Instance Method Summary collapse
- #accessors ⇒ String
- #declarations ⇒ String
- #ginny_class ⇒ Ginny::Class
- #initialize(summary, t_set_id) ⇒ void constructor
- #render ⇒ String
- #super_call ⇒ String
Constructor Details
#initialize(summary, t_set_id) ⇒ void
18 19 20 21 |
# File 'lib/eddy/build/loop/repeat.rb', line 18 def initialize(summary, t_set_id) self.summary = summary self.t_set_id = t_set_id end |
Instance Attribute Details
#summary ⇒ Eddy::Summary::Loop
10 11 12 |
# File 'lib/eddy/build/loop/repeat.rb', line 10 def summary @summary end |
#t_set_id ⇒ String
Namespace the Loop is within.
13 14 15 |
# File 'lib/eddy/build/loop/repeat.rb', line 13 def t_set_id @t_set_id end |
Instance Method Details
#accessors ⇒ String
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/eddy/build/loop/repeat.rb', line 72 def accessors() defs = self.summary.components.map do |comp| if comp.is_a?(Eddy::Summary::Loop) && comp.repeat_limit > 1 Eddy::Build::TransactionSetBuilder.loop_accessor(comp, self.t_set_id) else Eddy::Build::TransactionSetBuilder.segment_accessor(comp.id) end end return defs.join("\n\n") end |
#declarations ⇒ String
62 63 64 65 66 67 68 69 |
# File 'lib/eddy/build/loop/repeat.rb', line 62 def declarations() self.summary.components.map do |comp| case comp when Eddy::Summary::Segment then " @#{comp.id.downcase} = Eddy::Segments::#{comp.id.upcase}.new(store)" when Eddy::Summary::Loop then " @#{comp.var_name} = Eddy::TransactionSets::#{t_set_id}::Loops::#{comp.id.upcase}::Base.new(store)" end end.compact.join("\n") end |
#ginny_class ⇒ Ginny::Class
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/eddy/build/loop/repeat.rb', line 29 def ginny_class() return Ginny::Class.create({ classify_name: false, parent: "Eddy::Models::Loop::Repeat", name: "Repeat", description: "(see Eddy::TransactionSets::#{t_set_id}::Loops::#{self.summary.id}::Base)", body: <<~STR.strip, # @param store [Eddy::Data::Store] # @return [void] def initialize(store) #{self.declarations()} super( store, #{self.super_call()} ) end #{self.accessors()} STR }) end |
#render ⇒ String
24 25 26 |
# File 'lib/eddy/build/loop/repeat.rb', line 24 def render() return self.ginny_class.render() end |
#super_call ⇒ String
52 53 54 55 56 57 58 59 |
# File 'lib/eddy/build/loop/repeat.rb', line 52 def super_call() return self.summary.components.map do |comp| case comp when Eddy::Summary::Segment then " @#{comp.id.downcase}," when Eddy::Summary::Loop then " @#{comp.var_name}," end end.compact.join("\n ") end |