Module: Automatic::OPML

Defined in:
lib/automatic/opml.rb

Defined Under Namespace

Modules: DOM Classes: Parser

Class Method Summary collapse

Class Method Details

.unnormalize(text) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/automatic/opml.rb', line 6

def self::unnormalize(text)
  text.gsub(/&(\w+);/) {
    x = $1
    case x
    when 'lt'
      '<'
    when 'gt'
      '>'
    when 'quot'
      '"'
    when 'amp'
      '&'
    when 'apos'
      "'"
    when /^\#(\d+)$/
      [$1.to_i].pack("U")
    when /^\#x([0-9a-f]+)$/i
      [$1.hex].pack("U")
    else
      raise "unnormalize error '#{x}'"
    end
  }
end