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.



136
137
138
139
140
141
142
143
144
145
# File 'lib/stupidedi/schema/element_use.rb', line 136

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)


134
135
136
# File 'lib/stupidedi/schema/element_use.rb', line 134

def allowed_values
  @allowed_values
end

#definitionSimpleElementDef (readonly)

Returns:



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

def definition
  @definition
end

#parentCompositeElementDef (readonly)

Returns:



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

def parent
  @parent
end

#requirementElementReq (readonly)

Returns:



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

def requirement
  @requirement
end

Instance Method Details

#component?Boolean

Returns true.

Returns:

  • (Boolean)

    true



172
173
174
# File 'lib/stupidedi/schema/element_use.rb', line 172

def component?
  true
end

#copy(changes = {}) ⇒ ComponentElementUse

Returns:



148
149
150
151
152
153
154
# File 'lib/stupidedi/schema/element_use.rb', line 148

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)


157
158
159
# File 'lib/stupidedi/schema/element_use.rb', line 157

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

#pretty_print(q) ⇒ void

This method returns an undefined value.



177
178
179
180
181
182
183
184
185
186
# File 'lib/stupidedi/schema/element_use.rb', line 177

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



162
163
164
# File 'lib/stupidedi/schema/element_use.rb', line 162

def repeatable?
  false
end

#simple?Boolean

Returns true.

Returns:

  • (Boolean)

    true



167
168
169
# File 'lib/stupidedi/schema/element_use.rb', line 167

def simple?
  true
end