Class: Stupidedi::Schema::CompositeElementUse

Inherits:
AbstractElementUse show all
Defined in:
lib/stupidedi/schema/element_use.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElementUse

#composite?, #empty, #value

Methods included from Inspect

#inspect

Methods inherited from AbstractUse

#composite?, #definition?, #element?, #functional_group?, #interchange?, #loop?, #repeated?, #segment?, #table?, #transaction_set?, #usage?

Constructor Details

#initialize(definition, requirement, repeat_count, parent) ⇒ CompositeElementUse

Returns a new instance of CompositeElementUse.



199
200
201
202
203
204
205
206
207
208
# File 'lib/stupidedi/schema/element_use.rb', line 199

def initialize(definition, requirement, repeat_count, parent)
  @definition, @requirement, @repeat_count, @parent =
    definition, requirement, repeat_count, 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

#definitionCompositeElementDef (readonly)

Returns:



188
189
190
# File 'lib/stupidedi/schema/element_use.rb', line 188

def definition
  @definition
end

#parentSegmentDef (readonly)

Returns:



197
198
199
# File 'lib/stupidedi/schema/element_use.rb', line 197

def parent
  @parent
end

#repeat_countRepeatCount (readonly)

Returns:



194
195
196
# File 'lib/stupidedi/schema/element_use.rb', line 194

def repeat_count
  @repeat_count
end

#requirementElementReq (readonly)

Returns:



191
192
193
# File 'lib/stupidedi/schema/element_use.rb', line 191

def requirement
  @requirement
end

Instance Method Details

#component?Boolean

Returns false.

Returns:

  • (Boolean)

    false



229
230
231
# File 'lib/stupidedi/schema/element_use.rb', line 229

def component?
  false
end

#copy(changes = {}) ⇒ CompositeElementUse

Returns:



211
212
213
214
215
216
217
# File 'lib/stupidedi/schema/element_use.rb', line 211

def copy(changes = {})
  CompositeElementUse.new \
    changes.fetch(:definition, @definition),
    changes.fetch(:requirement, @requirement),
    changes.fetch(:repeat_count, @repeat_count),
    changes.fetch(:parent, @parent)
end

#pretty_print(q) ⇒ void

This method returns an undefined value.



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/stupidedi/schema/element_use.rb', line 234

def pretty_print(q)
  q.text("CompositeElementUse")
  q.group(2, "(", ")") do
    q.breakable ""
    q.pp @definition
    q.text ","

    q.breakable
    q.pp @requirement
    q.text ","

    q.breakable
    q.pp @repeat_count
  end
end

#repeatable?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/stupidedi/schema/element_use.rb', line 219

def repeatable?
  @repeat_count.try{|r| r.include?(2) }
end

#simple?Boolean

Returns false.

Returns:

  • (Boolean)

    false



224
225
226
# File 'lib/stupidedi/schema/element_use.rb', line 224

def simple?
  false
end