Class: Washcloth::Formatters::Xml
- Inherits:
-
Object
- Object
- Washcloth::Formatters::Xml
- Defined in:
- lib/washcloth.rb
Instance Method Summary collapse
-
#initialize(filter) ⇒ Xml
constructor
A new instance of Xml.
- #regexp ⇒ Object
- #run(value) ⇒ Object
Constructor Details
#initialize(filter) ⇒ Xml
Returns a new instance of Xml.
32 33 34 |
# File 'lib/washcloth.rb', line 32 def initialize(filter) @filter = filter end |
Instance Method Details
#regexp ⇒ Object
36 37 38 |
# File 'lib/washcloth.rb', line 36 def regexp /<#{@filter.name}>(?<inner>.*)<\/#{@filter.name}>/mi end |
#run(value) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/washcloth.rb', line 40 def run(value) value.gsub(regexp) do |match| last_match = Regexp.last_match[:inner] match.sub(last_match, @filter.filter[last_match]) end end |