class Eddy::Build::Loop::Repeat
Generate Ruby code from JSON/YAML EDI definitions.
Attributes
summary[RW]
@return [Eddy::Summary::Loop]
t_set_id[RW]
Namespace the Loop
is within. @return [String]
Public Class Methods
new(summary, t_set_id)
click to toggle source
@param summary [Eddy::Summary::Loop] @param t_set_id
[String] @return [void]
# 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
Public Instance Methods
accessors()
click to toggle source
@return [String]
# 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()
click to toggle source
@return [String]
# 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()
click to toggle source
@return [Ginny::Class]
# 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()
click to toggle source
@return [String]
# File lib/eddy/build/loop/repeat.rb, line 24 def render() return self.ginny_class.render() end
super_call()
click to toggle source
@return [String]
# 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