Module: XamplGenerator::ElementAsChild

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

Instance Method Summary collapse

Instance Method Details

#add_element(element) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 102

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

  existing = @element_child[index]

  self.remove_element(index) if existing and (existing != element)

  @children << element
  @element_child[index] = element

  element.add_parent(self)

  changed
  return element
end

#element_childObject Also known as: element



85
86
87
88
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 85

def element_child
  accessed
  @element_child
end

#element_child=(v) ⇒ Object Also known as: element=



90
91
92
93
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 90

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

#ensure_element(index) {|element| ... } ⇒ Object

Yields:



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 132

def ensure_element(index)
  accessed

  element = @element_child[index]
  return element if element

  element = Element.new(index) unless element

  yield(element) if block_given?
  return add_element(element)
end

#init_element_as_childObject



98
99
100
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 98

def init_element_as_child
  @element_child = IndexedArray.new
end

#new_element(index) {|element| ... } ⇒ Object

Yields:



122
123
124
125
126
127
128
129
130
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 122

def new_element(index)
  accessed

  element = nil
  element = Element.new(index) unless element

  yield(element) if block_given?
  return add_element(element)
end

#remove_element(index) ⇒ Object



144
145
146
147
148
149
150
151
152
# File 'lib/xamplr-gen/xampl-hand-generated.rb', line 144

def remove_element(index)
  accessed
  changed
  unless String === index or Symbol === index then
    index = index.get_the_index
  end
  element = @element_child.delete(index) if index
  @children.delete(element)
end