1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
# encoding: UTF-8
$KCODE = 'u' unless "1.9".respond_to?(:encoding)
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "htmlentities"
class HTMLEntitiesJob
def initialize
@coder = HTMLEntities.new
@decoded = File.read(File.join(File.dirname(__FILE__), "sample"))
@encoded = @coder.encode(@decoded, :basic, :named, :hexadecimal)
end
def encode(cycles)
cycles.times do
@coder.encode(@decoded, :basic, :named, :hexadecimal)
@coder.encode(@decoded, :basic, :named, :decimal)
end
end
def decode(cycles)
cycles.times do
@coder.decode(@encoded)
end
end
def all(cycles)
encode(cycles)
decode(cycles)
end
end
|