Class: Stupidedi::Schema::CompositeElementUse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElementUse

#composite?, #description, #empty, #id, #name, #value

Methods included from Inspect

#inspect

Methods inherited from AbstractUse

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

Constructor Details

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

Returns a new instance of CompositeElementUse.


21
22
23
24
25
26
27
28
29
30
# File 'lib/stupidedi/schema/composite_element_use.rb', line 21

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:


8
9
10
# File 'lib/stupidedi/schema/composite_element_use.rb', line 8

def definition
  @definition
end

#parentSegmentDef (readonly)

Returns:


19
20
21
# File 'lib/stupidedi/schema/composite_element_use.rb', line 19

def parent
  @parent
end

#repeat_countRepeatCount (readonly)

Returns:


16
17
18
# File 'lib/stupidedi/schema/composite_element_use.rb', line 16

def repeat_count
  @repeat_count
end

#requirementElementReq (readonly)

Returns:


13
14
15
# File 'lib/stupidedi/schema/composite_element_use.rb', line 13

def requirement
  @requirement
end

Instance Method Details

#component?Boolean

Returns false.

Returns:

  • (Boolean)

    false


56
57
58
# File 'lib/stupidedi/schema/composite_element_use.rb', line 56

def component?
  false
end

#copy(changes = {}) ⇒ CompositeElementUse

Returns:


33
34
35
36
37
38
39
# File 'lib/stupidedi/schema/composite_element_use.rb', line 33

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

#descriptor


41
42
43
44
# File 'lib/stupidedi/schema/composite_element_use.rb', line 41

def descriptor
  n = parent.element_uses.index{|u| u.eql?(self) } + 1
  "element #{parent.id}#{"%02d" % n} #{definition.name}".strip
end

#pretty_print(q)

This method returns an undefined value.


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/stupidedi/schema/composite_element_use.rb', line 61

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)

46
47
48
# File 'lib/stupidedi/schema/composite_element_use.rb', line 46

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

#simple?Boolean

Returns false.

Returns:

  • (Boolean)

    false


51
52
53
# File 'lib/stupidedi/schema/composite_element_use.rb', line 51

def simple?
  false
end