Class: Stupidedi::Schema::ComponentElementUse

Inherits:
AbstractElementUse show all
Defined in:
lib/stupidedi/schema/component_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, 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_valuesAbstractSet (readonly)

Returns:

  • (AbstractSet)

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

def allowed_values
  @allowed_values
end

#definitionSimpleElementDef (readonly)

Returns:


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

def definition
  @definition
end

#parentCompositeElementDef (readonly)

Returns:


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

def parent
  @parent
end

#requirementElementReq (readonly)

Returns:


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

def requirement
  @requirement
end

Instance Method Details

#component?Boolean

Returns true.

Returns:

  • (Boolean)

    true


59
60
61
# File 'lib/stupidedi/schema/component_element_use.rb', line 59

def component?
  true
end

#copy(changes = {}) ⇒ ComponentElementUse

Returns:


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

#descriptorString

Returns:

  • (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.

Returns:

  • (Boolean)

    false


49
50
51
# File 'lib/stupidedi/schema/component_element_use.rb', line 49

def repeatable?
  false
end

#simple?Boolean

Returns true.

Returns:

  • (Boolean)

    true


54
55
56
# File 'lib/stupidedi/schema/component_element_use.rb', line 54

def simple?
  true
end