Class: Xampl::RemoveWhitespaceContentVisitor

Inherits:
Visitor
  • Object
show all
Defined in:
lib/xamplr/visitors.rb

Instance Attribute Summary

Attributes inherited from Visitor

#done, #no_children, #no_siblings

Instance Method Summary collapse

Methods inherited from Visitor

#around_visit, #before_visit, #cycle, #method_missing, #reset, #revisit, #short_circuit, #start, #substitute_in_visit, #visit_string

Constructor Details

#initializeRemoveWhitespaceContentVisitor

This can be useful for cleaning up DSLs embedded in XML/xampl



8
9
10
# File 'lib/xamplr/visitors.rb', line 8

def initialize
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Xampl::Visitor

Instance Method Details

#after_visit(xampl) ⇒ Object



12
13
14
# File 'lib/xamplr/visitors.rb', line 12

def after_visit(xampl)
  xampl.after_visit_by_element_kind(self) if xampl.respond_to? "after_visit_by_element_kind"
end

#after_visit_data_content(xampl) ⇒ Object



21
22
23
24
# File 'lib/xamplr/visitors.rb', line 21

def after_visit_data_content(xampl)
  text = xampl.content
  xampl.content = nil if text && text.match(/\S/).nil?
end

#after_visit_simple_content(xampl) ⇒ Object



16
17
18
19
# File 'lib/xamplr/visitors.rb', line 16

def after_visit_simple_content(xampl)
  text = xampl.content
  xampl.content = nil if text && text.match(/\S/).nil?
end