Class: Stupidedi::Schema::ComponentElementUse
- Inherits:
-
AbstractElementUse
- Object
- AbstractUse
- AbstractElementUse
- Stupidedi::Schema::ComponentElementUse
- Defined in:
- lib/stupidedi/schema/component_element_use.rb
Instance Attribute Summary collapse
- #allowed_values ⇒ AbstractSet readonly
- #definition ⇒ SimpleElementDef readonly
- #parent ⇒ CompositeElementDef readonly
- #requirement ⇒ ElementReq readonly
Instance Method Summary collapse
-
#component? ⇒ Boolean
True.
- #copy(changes = {}) ⇒ ComponentElementUse
- #descriptor ⇒ String
-
#initialize(definition, requirement, allowed_values, parent) ⇒ ComponentElementUse
constructor
A new instance of ComponentElementUse.
- #pretty_print(q)
-
#repeatable? ⇒ Boolean
False.
-
#simple? ⇒ Boolean
True.
Methods inherited from AbstractElementUse
#composite?, #description, #empty, #id, #name, #value
Methods included from Inspect
Methods inherited from AbstractUse
#composite?, #definition?, #element?, #functional_group?, #id, #interchange?, #loop?, #repeated?, #segment?, #table?, #transaction_set?, #usage?
Constructor Details
#initialize(definition, requirement, allowed_values, parent) ⇒ ComponentElementUse
Returns a new instance of ComponentElementUse.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 21 def initialize(definition, requirement, allowed_values, parent) @definition, @requirement, @allowed_values, @parent = definition, requirement, allowed_values, parent # Delay re-parenting until the entire definition tree has a root # to prevent unnecessarily copying objects unless parent.nil? @definition = @definition.copy(:parent => self) end end |
Instance Attribute Details
#allowed_values ⇒ AbstractSet (readonly)
19 20 21 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 19 def allowed_values @allowed_values end |
#definition ⇒ SimpleElementDef (readonly)
8 9 10 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 8 def definition @definition end |
#parent ⇒ CompositeElementDef (readonly)
16 17 18 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 16 def parent @parent end |
#requirement ⇒ ElementReq (readonly)
13 14 15 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 13 def requirement @requirement end |
Instance Method Details
#component? ⇒ Boolean
Returns true.
59 60 61 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 59 def component? true end |
#copy(changes = {}) ⇒ ComponentElementUse
33 34 35 36 37 38 39 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 33 def copy(changes = {}) ComponentElementUse.new \ changes.fetch(:definition, @definition), changes.fetch(:requirement, @requirement), changes.fetch(:allowed_values, @allowed_values), changes.fetch(:parent, @parent) end |
#descriptor ⇒ String
42 43 44 45 46 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 42 def descriptor n = parent.parent.parent.element_uses.index{|u| u.eql?(parent.parent) } + 1 m = parent.component_uses.index{|u| u.eql?(self) } + 1 "element #{parent.parent.parent.id}#{"%02d-%02d" % [n, m]} #{definition.name}".strip end |
#pretty_print(q)
This method returns an undefined value.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 64 def pretty_print(q) q.text("ComponentElementUse") q.group(2, "(", ")") do q.breakable "" q.pp @definition q.text "," q.breakable q.pp @requirement end end |
#repeatable? ⇒ Boolean
Returns false.
49 50 51 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 49 def repeatable? false end |
#simple? ⇒ Boolean
Returns true.
54 55 56 |
# File 'lib/stupidedi/schema/component_element_use.rb', line 54 def simple? true end |