Class: Lutaml::Model::Schema::XmlCompiler::Choice

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

Constant Summary collapse

INDENT =
"  "
TEMPLATE =
ERB.new("<%= indent %>choice<%= block_options %> do\n<%= instances.map { |instance| instance.to_attributes(indent + INDENT) }.join -%>\n<%= indent %>end\n", trim_mode: "-")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChoice

Returns a new instance of Choice.



18
19
20
# File 'lib/lutaml/model/schema/xml_compiler/choice.rb', line 18

def initialize
  @instances = []
end

Instance Attribute Details

#instancesObject

Returns the value of attribute instances.



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

def instances
  @instances
end

#max_occursObject

Returns the value of attribute max_occurs.



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

def max_occurs
  @max_occurs
end

#min_occursObject

Returns the value of attribute min_occurs.



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

def min_occurs
  @min_occurs
end

Instance Method Details

#<<(instance) ⇒ Object



22
23
24
25
26
# File 'lib/lutaml/model/schema/xml_compiler/choice.rb', line 22

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

  @instances << instance
end

#required_filesObject



36
37
38
# File 'lib/lutaml/model/schema/xml_compiler/choice.rb', line 36

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

#to_attributes(indent = INDENT) ⇒ Object



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

def to_attributes(indent = INDENT)
  TEMPLATE.result(binding)
end

#to_xml_mapping(indent = INDENT) ⇒ Object



32
33
34
# File 'lib/lutaml/model/schema/xml_compiler/choice.rb', line 32

def to_xml_mapping(indent = INDENT)
  instances.filter_map { |instance| instance.to_xml_mapping(indent) }.join
end