Module: Xampl::XamplWithMixedContent
- Defined in:
- lib/xamplr/mixins.rb
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #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_mixed_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
387 388 389 390 391 392 393 394 |
# File 'lib/xamplr/mixins.rb', line 387 def <<(other) if (other.respond_to?("append_to")) other.append_to(self) else add_content(other) end return self end |
#add_content(new_content, tokenise = false) ⇒ Object
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/xamplr/mixins.rb', line 317 def add_content(new_content, tokenise=false) return if nil == new_content accessed new_content = new_content.to_s last_child = @children.last if last_child and (last_child.kind_of? String) then last_child << new_content FromXML.tokenise_string(last_child, false) if tokenise else FromXML.tokenise_string(new_content, false) if tokenise new_content.extend(XamplExtensionsToRubyObjects) @children << new_content unless 0 == new_content.size end changed end |
#after_visit_by_element_kind(visitor) ⇒ Object
308 309 310 |
# File 'lib/xamplr/mixins.rb', line 308 def after_visit_by_element_kind(visitor) visitor.after_visit_mixed_content(self) end |
#before_visit_by_element_kind(visitor) ⇒ Object
300 301 302 |
# File 'lib/xamplr/mixins.rb', line 300 def before_visit_by_element_kind(visitor) visitor.before_visit_mixed_content(self) end |
#children ⇒ Object
312 313 314 315 |
# File 'lib/xamplr/mixins.rb', line 312 def children accessed return @children end |
#has_mixed_content ⇒ Object
296 297 298 |
# File 'lib/xamplr/mixins.rb', line 296 def has_mixed_content true end |
#init_mixed_content ⇒ Object
292 293 294 |
# File 'lib/xamplr/mixins.rb', line 292 def init_mixed_content @children = [] if not defined? @children end |
#initialize ⇒ Object
287 288 289 290 |
# File 'lib/xamplr/mixins.rb', line 287 def initialize super init_mixed_content end |
#test_to_xml(out = "", rules = nil) ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/xamplr/mixins.rb', line 336 def test_to_xml(out="", rules=nil) accessed rules = XMLPrinter.new(out) if nil == rules rules.attribute(self) if (0 == children.length) rules.start_root_element(tag, ns, true) rules.end_root_element(tag, ns, true) else rules.start_root_element(tag, ns, false) rules.now_as_mixed children.each{ | child | if (child.respond_to? "test_to_xml_internal") child.test_to_xml_internal(rules) else rules._content(child) end } rules.now_as_before rules.end_root_element(tag, ns, false) end return rules.done end |
#test_to_xml_internal(rules) ⇒ Object
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/xamplr/mixins.rb', line 361 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) rules.start_element(tag, ns, true) rules.end_element(tag, ns, true) else rules.start_element(tag, ns, false) rules.now_as_mixed children.each{ | child | if (child.respond_to? "test_to_xml_internal") child.test_to_xml_internal(rules) else rules._content(child) end } rules.now_as_before rules.end_element(tag, ns, false) end end |
#visit_by_element_kind(visitor) ⇒ Object
304 305 306 |
# File 'lib/xamplr/mixins.rb', line 304 def visit_by_element_kind(visitor) visitor.visit_mixed_content(self) end |