Class: Lutaml::Model::Schema::XmlCompiler::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/schema/xml_compiler/sequence.rb

Constant Summary collapse

XML_MAPPING_TEMPLATE =
ERB.new(<<~TEMPLATE, trim_mode: "-")
  <%= indent %>sequence do
  <%= content -%>
  <%= indent %>end
TEMPLATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSequence

Returns a new instance of Sequence.



16
17
18
# File 'lib/lutaml/model/schema/xml_compiler/sequence.rb', line 16

def initialize
  @instances = []
end

Instance Attribute Details

#instancesObject

Returns the value of attribute instances.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/sequence.rb', line 8

def instances
  @instances
end

Instance Method Details

#<<(instance) ⇒ Object



20
21
22
23
24
# File 'lib/lutaml/model/schema/xml_compiler/sequence.rb', line 20

def <<(instance)
  return if instance.nil?

  @instances << instance
end

#required_filesObject



39
40
41
# File 'lib/lutaml/model/schema/xml_compiler/sequence.rb', line 39

def required_files
  @instances.map(&:required_files)
end

#to_attributes(indent) ⇒ Object



26
27
28
29
30
# File 'lib/lutaml/model/schema/xml_compiler/sequence.rb', line 26

def to_attributes(indent)
  instances.filter_map do |instance|
    instance.to_attributes(indent)
  end.join
end

#to_xml_mapping(indent) ⇒ Object



32
33
34
35
36
37
# File 'lib/lutaml/model/schema/xml_compiler/sequence.rb', line 32

def to_xml_mapping(indent)
  content = xml_block_content(indent)
  return "" if content.empty?

  XML_MAPPING_TEMPLATE.result(binding)
end