Module: DwcaHunter::XML
- Defined in:
- lib/dwca_hunter/xml.rb
Class Method Summary collapse
Class Method Details
.escape(input) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dwca_hunter/xml.rb', line 3 def self.escape(input) result = input.dup.strip result.gsub!(/[&<>'"]/) do | match | case match when '&' then '&' when '<' then '<' when '>' then '>' when "'" then ''' when '"' then '"' end end result end |
.unescape(input) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dwca_hunter/xml.rb', line 18 def self.unescape(input) result = input.dup.strip result.gsub!(/&[a-z]+;/) do | match | case match when '&' then '&' when '<' then '<' when '>' then '>' when ''' then "'" when '"' then '"' end end result end |