Class: Stupidedi::Schema::SimpleElementUse

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, allowed_values, parent) ⇒ SimpleElementUse

Returns a new instance of SimpleElementUse.



53
54
55
56
57
58
59
60
61
62
# File 'lib/stupidedi/schema/element_use.rb', line 53

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)


48
49
50
# File 'lib/stupidedi/schema/element_use.rb', line 48

def allowed_values
  @allowed_values
end

#definitionSimpleElementDef (readonly)

Returns:



39
40
41
# File 'lib/stupidedi/schema/element_use.rb', line 39

def definition
  @definition
end

#parentSegmentDef (readonly)

Returns:



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

def parent
  @parent
end

#repeat_countRepeatCount (readonly)

Returns:



45
46
47
# File 'lib/stupidedi/schema/element_use.rb', line 45

def repeat_count
  @repeat_count
end

#requirementElementReq (readonly)

Returns:



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

def requirement
  @requirement
end

Instance Method Details

#code_listsAbstractSet<CodeList>

Returns:



94
95
96
97
98
99
100
# File 'lib/stupidedi/schema/element_use.rb', line 94

def code_lists
  if forbidden?
    Sets.empty
  else
    @definition.code_lists(@allowed_values)
  end
end

#component?Boolean

Returns false.

Returns:

  • (Boolean)

    false



89
90
91
# File 'lib/stupidedi/schema/element_use.rb', line 89

def component?
  false
end

#copy(changes = {}) ⇒ SimpleElementUse

Returns:



65
66
67
68
69
70
71
72
# File 'lib/stupidedi/schema/element_use.rb', line 65

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

#parse(string) ⇒ SimpleElementVal

Returns:

  • (SimpleElementVal)


75
76
77
# File 'lib/stupidedi/schema/element_use.rb', line 75

def parse(string)
  definition.parse(string, self)
end

#pretty_print(q) ⇒ void

This method returns an undefined value.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/stupidedi/schema/element_use.rb', line 103

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)


79
80
81
# File 'lib/stupidedi/schema/element_use.rb', line 79

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

#simple?Boolean

Returns true.

Returns:

  • (Boolean)

    true



84
85
86
# File 'lib/stupidedi/schema/element_use.rb', line 84

def simple?
  true
end