Class: Stupidedi::Schema::CompositeElementDef
- Inherits:
-
AbstractElementDef
- Object
- AbstractDef
- AbstractElementDef
- Stupidedi::Schema::CompositeElementDef
- Defined in:
- lib/stupidedi/schema/composite_element_def.rb
Overview
Instance Attribute Summary collapse
- #component_uses ⇒ Array<ComponentElementUse> readonly
- #parent ⇒ CompositeElementUse readonly
- #syntax_notes ⇒ Array<SyntaxNote> readonly
Attributes inherited from AbstractElementDef
Constructors collapse
Instance Method Summary collapse
- #code_lists ⇒ AbstractSet<CodeList>
-
#composite? ⇒ Boolean
True.
- #copy(changes = {}) ⇒ CompositeElementDef
- #empty(usage, position) ⇒ CompositeElementVal
-
#initialize(id, name, description, component_uses, syntax_notes, parent) ⇒ CompositeElementDef
constructor
A new instance of CompositeElementDef.
- #pretty_print(q)
-
#simple? ⇒ Boolean
False.
- #simple_use(requirement, repeat_count, parent = nil) ⇒ CompositeElementUse
- #value(component_vals, usage, position) ⇒ CompositeElementVal
Methods inherited from AbstractElementDef
Methods included from Inspect
Methods inherited from AbstractDef
#component?, #definition?, #descriptor, #element?, #functional_group?, #interchange?, #loop?, #repeated?, #required?, #segment?, #table?, #transaction_set?, #usage?
Constructor Details
#initialize(id, name, description, component_uses, syntax_notes, parent) ⇒ CompositeElementDef
Returns a new instance of CompositeElementDef.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 19 def initialize(id, name, description, component_uses, syntax_notes, parent) @id, @name, @description, @component_uses, @syntax_notes, @parent = id, name, description, component_uses, syntax_notes, parent # Delay re-parenting until the entire definition tree has a root # to prevent unnecessarily copying objects unless parent.nil? @component_uses = @component_uses.map{|x| x.copy(:parent => self) } end end |
Instance Attribute Details
#component_uses ⇒ Array<ComponentElementUse> (readonly)
11 12 13 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 11 def component_uses @component_uses end |
#parent ⇒ CompositeElementUse (readonly)
17 18 19 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 17 def parent @parent end |
#syntax_notes ⇒ Array<SyntaxNote> (readonly)
14 15 16 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 14 def syntax_notes @syntax_notes end |
Class Method Details
.build(id, name, description, *args) ⇒ CompositeElementDef
92 93 94 95 96 97 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 92 def build(id, name, description, *args) component_uses = args.take_while{|x| x.is_a?(AbstractElementUse) } syntax_notes = args.drop(component_uses.length) new(id, name, description, component_uses, syntax_notes, nil) end |
Instance Method Details
#code_lists ⇒ AbstractSet<CodeList>
67 68 69 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 67 def code_lists @component_uses.map(&:code_lists).inject(&:|) end |
#composite? ⇒ Boolean
Returns true.
47 48 49 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 47 def composite? true end |
#copy(changes = {}) ⇒ CompositeElementDef
31 32 33 34 35 36 37 38 39 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 31 def copy(changes = {}) CompositeElementDef.new \ changes.fetch(:id, @id), changes.fetch(:name, @name), changes.fetch(:description, @description), changes.fetch(:component_uses, @component_uses), changes.fetch(:syntax_notes, @syntax_notes), changes.fetch(:parent, @parent) end |
#empty(usage, position) ⇒ CompositeElementVal
62 63 64 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 62 def empty(usage, position) Values::CompositeElementVal.new([], usage) end |
#pretty_print(q)
This method returns an undefined value.
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 72 def pretty_print(q) q.text("CompositeElementDef[#{@id}]") q.group(2, "(", ")") do q.breakable "" @component_uses.each do |e| unless q.current_group.first? q.text "," q.breakable end q.pp e end end end |
#simple? ⇒ Boolean
Returns false.
42 43 44 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 42 def simple? false end |
#simple_use(requirement, repeat_count, parent = nil) ⇒ CompositeElementUse
52 53 54 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 52 def simple_use(requirement, repeat_count, parent = nil) CompositeElementUse.new(self, requirement, repeat_count, parent) end |
#value(component_vals, usage, position) ⇒ CompositeElementVal
57 58 59 |
# File 'lib/stupidedi/schema/composite_element_def.rb', line 57 def value(component_vals, usage, position) Values::CompositeElementVal.new(component_vals, usage) end |