Module: XamplGenerator::ChildElementAsChild

Included in:
Element
Defined in:
lib/xamplr-gen/xampl-hand-generated.rb

Instance Method Summary collapse

Instance Method Details

#add_child_element(child_element) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 175

def add_child_element(child_element)
  accessed
  index = child_element.get_the_index
  if (nil == index) then
    throw "no value for the index 'name' of child_element defined in : " << child_element.pp_xml
  end

  existing = @child_element_child[index]

  self.remove_child_element(index) if existing and (existing != child_element)

  @children << child_element
  @child_element_child[index] = child_element

  child_element.add_parent(self)

  changed
  return child_element
end

#child_element_childObject Also known as: child_element



158
159
160
161
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 158

def child_element_child
  accessed
  @child_element_child
end

#child_element_child=(v) ⇒ Object Also known as: child_element=



163
164
165
166
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 163

def child_element_child=(v)
  accessed
  @child_element_child = v
end

#ensure_child_element(index) {|child_element| ... } ⇒ Object

Yields:



205
206
207
208
209
210
211
212
213
214
215
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 205

def ensure_child_element(index)
  accessed

  child_element = @child_element_child[index]
  return child_element if child_element

  child_element = ChildElement.new(index) unless child_element

  yield(child_element) if block_given?
  return add_child_element(child_element)
end

#init_child_element_as_childObject



171
172
173
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 171

def init_child_element_as_child
  @child_element_child = IndexedArray.new
end

#new_child_element(index) {|child_element| ... } ⇒ Object

Yields:



195
196
197
198
199
200
201
202
203
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 195

def new_child_element(index)
  accessed

  child_element = nil
  child_element = ChildElement.new(index) unless child_element

  yield(child_element) if block_given?
  return add_child_element(child_element)
end

#remove_child_element(index) ⇒ Object



217
218
219
220
221
222
223
224
225
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 217

def remove_child_element(index)
  accessed
  changed
  unless String === index or Symbol === index then
    index = index.get_the_index
  end
  child_element = @child_element_child.delete(index) if index
  @children.delete(child_element)
end