Module: Lutaml::Model::Schema::ModuleNesting

Defined in:
lib/lutaml/model/schema/module_nesting.rb

Overview

Stateless helpers for emitting module Foo ... end wrappers around generated code, given an Array of module-name segments.

Both helpers return a single newline-terminated block (no trailing newline) so ERB templates should use <%= ... -%> to avoid doubling the line break.

Class Method Summary collapse

Class Method Details

.closing(modules) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/lutaml/model/schema/module_nesting.rb', line 21

def closing(modules)
  return "" if modules.empty?

  modules.reverse.map.with_index do |_m, i|
    "#{'  ' * (modules.size - i - 1)}end\n"
  end.join
end

.opening(modules) ⇒ Object



15
16
17
18
19
# File 'lib/lutaml/model/schema/module_nesting.rb', line 15

def opening(modules)
  return "" if modules.empty?

  modules.map.with_index { |m, i| "#{'  ' * i}module #{m}\n" }.join
end