Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/serenity/serenity/escape_xml.rb
Instance Method Summary collapse
Instance Method Details
#convert_newlines ⇒ Object
6 7 8 9 |
# File 'lib/serenity/serenity/escape_xml.rb', line 6 def convert_newlines gsub!("\n", '<text:line-break/>') self end |
#escape_xml ⇒ Object
2 3 4 |
# File 'lib/serenity/serenity/escape_xml.rb', line 2 def escape_xml mgsub!([[/&/, '&'], [/</, '<'], [/>/, '>']]) end |
#mgsub!(key_value_pairs = [].freeze) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/serenity/serenity/escape_xml.rb', line 11 def mgsub!(key_value_pairs=[].freeze) regexp_fragments = key_value_pairs.collect { |k,v| k } gsub!(Regexp.union(*regexp_fragments)) do |match| key_value_pairs.detect{|k,v| k =~ match}[1] end self end |