Module: Xampl::XamplWithDataContent
- Defined in:
- lib/xamplr/mixins.rb
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #_content ⇒ Object (also: #content)
- #_content=(v) ⇒ Object (also: #content=)
- #add_content(new_content, tokenise = false) ⇒ Object
- #after_visit_by_element_kind(visitor) ⇒ Object
- #before_visit_by_element_kind(visitor) ⇒ Object
- #children ⇒ Object
- #has_mixed_content ⇒ Object
- #init_data_content ⇒ Object
- #initialize ⇒ Object
- #test_to_xml(out = "", rules = nil) ⇒ Object
- #test_to_xml_internal(rules) ⇒ Object
- #visit_by_element_kind(visitor) ⇒ Object
Instance Method Details
#<<(other) ⇒ Object
276 277 278 279 280 281 282 283 |
# File 'lib/xamplr/mixins.rb', line 276 def <<(other) if (other.respond_to?("append_to")) other.append_to(self) else add_content(other) end return self end |
#_content ⇒ Object Also known as: content
202 203 204 205 |
# File 'lib/xamplr/mixins.rb', line 202 def _content accessed @_content end |
#_content=(v) ⇒ Object Also known as: content=
207 208 209 210 211 212 213 |
# File 'lib/xamplr/mixins.rb', line 207 def _content=(v) accessed v = v.to_s if (v.kind_of? Symbol) and !Xampl.xampl_extends_symbols v.extend(XamplExtensionsToRubyObjects) unless v.kind_of? Symbol @_content = v changed end |
#add_content(new_content, tokenise = false) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/xamplr/mixins.rb', line 218 def add_content(new_content, tokenise=false) return if nil == new_content accessed if (nil == @_content) then @_content = new_content.to_s @_content.extend(XamplExtensionsToRubyObjects) else @_content << new_content.to_s end FromXML.tokenise_string(@_content, false) if tokenise @_content = nil if 0 == @_content.size changed end |
#after_visit_by_element_kind(visitor) ⇒ Object
188 189 190 |
# File 'lib/xamplr/mixins.rb', line 188 def after_visit_by_element_kind(visitor) visitor.after_visit_data_content(self) end |
#before_visit_by_element_kind(visitor) ⇒ Object
180 181 182 |
# File 'lib/xamplr/mixins.rb', line 180 def before_visit_by_element_kind(visitor) visitor.before_visit_data_content(self) end |
#children ⇒ Object
197 198 199 200 |
# File 'lib/xamplr/mixins.rb', line 197 def children accessed return @children end |
#has_mixed_content ⇒ Object
176 177 178 |
# File 'lib/xamplr/mixins.rb', line 176 def has_mixed_content false end |
#init_data_content ⇒ Object
192 193 194 195 |
# File 'lib/xamplr/mixins.rb', line 192 def init_data_content @_content = nil if not defined? @_content @children = [] if not defined? @children end |
#initialize ⇒ Object
171 172 173 174 |
# File 'lib/xamplr/mixins.rb', line 171 def initialize super init_data_content end |
#test_to_xml(out = "", rules = nil) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/xamplr/mixins.rb', line 235 def test_to_xml(out="", rules=nil) accessed rules = XMLPrinter.new(out) if nil == rules rules.attribute(self) if (0 == children.length) && (nil == content) rules.start_root_element(tag, ns, true) rules.end_root_element(tag, ns, true) else rules.start_root_element(tag, ns, false) rules._content(content) children.each{ | child | child.test_to_xml_internal(rules) } rules.end_root_element(tag, ns, false) end return rules.done end |
#test_to_xml_internal(rules) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/xamplr/mixins.rb', line 255 def test_to_xml_internal(rules) if rules.persisting && self.persist_required then rules.persist_attribute(self) rules.persisted_element(tag, ns) return end rules.attribute(self) if (self.persist_required && self.load_needed) || ((0 == children.length) && (nil == content)) rules.start_element(tag, ns, true) rules.end_element(tag, ns, true) else rules.start_element(tag, ns, false) rules._content(content) children.each{ | child | child.test_to_xml_internal(rules) } rules.end_element(tag, ns, false) end end |
#visit_by_element_kind(visitor) ⇒ Object
184 185 186 |
# File 'lib/xamplr/mixins.rb', line 184 def visit_by_element_kind(visitor) visitor.visit_data_content(self) end |