Class: Lutaml::Model::Schema::XmlCompiler::Choice
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::XmlCompiler::Choice
- 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
-
#instances ⇒ Object
Returns the value of attribute instances.
-
#max_occurs ⇒ Object
Returns the value of attribute max_occurs.
-
#min_occurs ⇒ Object
Returns the value of attribute min_occurs.
Instance Method Summary collapse
- #<<(instance) ⇒ Object
-
#initialize ⇒ Choice
constructor
A new instance of Choice.
- #required_files ⇒ Object
- #to_attributes(indent = INDENT) ⇒ Object
- #to_xml_mapping(indent = INDENT) ⇒ Object
Constructor Details
#initialize ⇒ Choice
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
#instances ⇒ Object
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_occurs ⇒ Object
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_occurs ⇒ Object
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_files ⇒ Object
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 |