Class: Stupidedi::Schema::ComponentElementUse

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

Returns a new instance of ComponentElementUse.



133
134
135
136
137
138
139
140
141
142
# File 'lib/stupidedi/schema/element_use.rb', line 133

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)


131
132
133
# File 'lib/stupidedi/schema/element_use.rb', line 131

def allowed_values
  @allowed_values
end

#definitionSimpleElementDef (readonly)

Returns:



122
123
124
# File 'lib/stupidedi/schema/element_use.rb', line 122

def definition
  @definition
end

#parentCompositeElementDef (readonly)

Returns:



128
129
130
# File 'lib/stupidedi/schema/element_use.rb', line 128

def parent
  @parent
end

#requirementElementReq (readonly)

Returns:



125
126
127
# File 'lib/stupidedi/schema/element_use.rb', line 125

def requirement
  @requirement
end

Instance Method Details

#component?Boolean

Returns true.

Returns:

  • (Boolean)

    true



169
170
171
# File 'lib/stupidedi/schema/element_use.rb', line 169

def component?
  true
end

#copy(changes = {}) ⇒ ComponentElementUse

Returns:



145
146
147
148
149
150
151
# File 'lib/stupidedi/schema/element_use.rb', line 145

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

#parse(string) ⇒ SimpleElementVal

Returns:

  • (SimpleElementVal)


154
155
156
# File 'lib/stupidedi/schema/element_use.rb', line 154

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

#pretty_print(q) ⇒ void

This method returns an undefined value.



174
175
176
177
178
179
180
181
182
183
# File 'lib/stupidedi/schema/element_use.rb', line 174

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



159
160
161
# File 'lib/stupidedi/schema/element_use.rb', line 159

def repeatable?
  false
end

#simple?Boolean

Returns true.

Returns:

  • (Boolean)

    true



164
165
166
# File 'lib/stupidedi/schema/element_use.rb', line 164

def simple?
  true
end