107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/elibri_onix_generator.rb', line 107
def initialize(products, options = {})
options[:export_headers] = true unless options.has_key?(:export_headers)
options[:elibri_onix_dialect] = DEFAULT_DIALECT unless options.has_key?(:elibri_onix_dialect)
options[:comments] = false unless options.has_key?(:comments)
options[:xml_variant] = OpenStruct.new(blank?: false,
includes_basic_meta?: true,
includes_other_texts?: true,
includes_media_files?: true,
includes_stocks?: true) unless options.has_key?(:xml_variant)
@xml_variant = options[:xml_variant]
raise ":xml_variant unspecified" if @xml_variant.blank?
if products.respond_to?(:to_ary)
@products = products.to_ary
else
@products = [products]
end
@comments = options[:comments]
@comment_kinds = options[:comment_kinds]
@out = []
@builder = Builder::XmlMarkup.new(:indent => 2, :target => @out)
@elibri_onix_dialect = options[:elibri_onix_dialect]
@pure_onix = options[:pure_onix] || options[:elibri_onix_dialect] == '3.0.2'
@skip_sourcename_and_timestamp = !!options[:skip_sourcename_and_timestamp]
@sender_name = options[:sender_name]
@lan = options[:lan] || "pol"
if options[:export_headers]
self.class.(@builder, elibri_onix_dialect: @elibri_onix_dialect, pure_onix: @pure_onix || !@xml_variant.includes_basic_meta?, sender_name: @sender_name) do
render_products!
end
else
render_products!
end
end
|