Class: Stupidedi::Schema::SimpleElementUse

Inherits:
AbstractElementUse show all
Defined in:
lib/stupidedi/schema/simple_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, allowed_values, parent) ⇒ SimpleElementUse

Returns a new instance of SimpleElementUse.



24
25
26
27
28
29
30
31
32
33
# File 'lib/stupidedi/schema/simple_element_use.rb', line 24

def initialize(definition, requirement, repeat_count, allowed_values, parent)
  @definition, @requirement, @repeat_count, @allowed_values, @parent =
    definition, requirement, repeat_count, 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/simple_element_use.rb', line 19

def allowed_values
  @allowed_values
end

#definitionSimpleElementDef (readonly)

Returns:



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

def definition
  @definition
end

#parentSegmentDef (readonly)

Returns:



22
23
24
# File 'lib/stupidedi/schema/simple_element_use.rb', line 22

def parent
  @parent
end

#repeat_countRepeatCount (readonly)

Returns:



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

def repeat_count
  @repeat_count
end

#requirementElementReq (readonly)

Returns:



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

def requirement
  @requirement
end

Instance Method Details

#component?Boolean

Returns false.

Returns:

  • (Boolean)

    false



61
62
63
# File 'lib/stupidedi/schema/simple_element_use.rb', line 61

def component?
  false
end

#copy(changes = {}) ⇒ SimpleElementUse

Returns:



36
37
38
39
40
41
42
43
# File 'lib/stupidedi/schema/simple_element_use.rb', line 36

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

#descriptorString

Returns:

  • (String)


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

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

#pretty_print(q)

This method returns an undefined value.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/stupidedi/schema/simple_element_use.rb', line 66

def pretty_print(q)
  q.text("SimpleElementUse")
  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)


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

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

#simple?Boolean

Returns true.

Returns:

  • (Boolean)

    true



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

def simple?
  true
end