Module: Utilities

Defined in:
lib/reparcs/utilities.rb

Overview

Useful utilities

Instance Method Summary collapse

Instance Method Details

#put_xml_entities(text) ⇒ Object

Replaces invalid XML characters (£, <, >, etc with there xml entity)



4
5
6
7
8
9
10
# File 'lib/reparcs/utilities.rb', line 4

def put_xml_entities(text)
  new_t = text
  ENTITIES.each do |key, val|
    new_t = new_t.gsub(key, val)
  end
  return new_t
end

#remove_xml_entities(text) ⇒ Object

Replaces XML entities with the equivalent character.



12
13
14
15
16
17
18
# File 'lib/reparcs/utilities.rb', line 12

def remove_xml_entities(text)
  new_t = text
  ENTITIES.each do |key, val|
    new_t = new_t.gsub(val, key)
  end
  return new_t
end