From 770e4ebfed0e015f0ed769b74ad0b5d2c0c9ea8a Mon Sep 17 00:00:00 2001 From: Tom-Eric Gerritsen Date: Fri, 6 Apr 2012 06:38:39 +0200 Subject: [PATCH] Remove #[] method from Transliterator::Base instances --- lib/transliterator/base.rb | 6 +----- spec/transliterator/base_spec.rb | 10 ---------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/transliterator/base.rb b/lib/transliterator/base.rb index 2c855c6..d369055 100644 --- a/lib/transliterator/base.rb +++ b/lib/transliterator/base.rb @@ -61,10 +61,6 @@ def initialize end end - def [](codepoint) - approximations[codepoint] || codepoint - end - # Transliterate a given string's UTF-8 characters to their ASCII equivalants. # # transliterator = Transliterator::Base.instance @@ -73,7 +69,7 @@ def [](codepoint) # @return [String] The transliterated string def transliterate(string) string.unpack("U*") - .map { |char| self[char] } + .map { |codepoint| approximations[codepoint] || codepoint } .flatten .pack("U*") end diff --git a/spec/transliterator/base_spec.rb b/spec/transliterator/base_spec.rb index 426866f..88a15e0 100644 --- a/spec/transliterator/base_spec.rb +++ b/spec/transliterator/base_spec.rb @@ -24,16 +24,6 @@ end end - describe '#[]' do - it 'returns the approximation for the given codepoint' do - subject[215].should == 120 - end - - it 'returns the codepoint if an approximation is not found' do - subject[97].should == 97 - end - end - describe '#transliterate' do it 'transliterates math related characters' do subject.transliterate("5 × 10 ÷ 2 ‐ 5 = 20").should == '5 x 10 / 2 - 5 = 20'