Skip to content
Browse files

Remove #[] method from Transliterator::Base instances

  • Loading branch information...
1 parent 84a13b3 commit 770e4ebfed0e015f0ed769b74ad0b5d2c0c9ea8a @tomeric tomeric committed Apr 6, 2012
Showing with 1 addition and 15 deletions.
  1. +1 −5 lib/transliterator/base.rb
  2. +0 −10 spec/transliterator/base_spec.rb
View
6 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
View
10 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'

0 comments on commit 770e4eb

Please sign in to comment.
Something went wrong with that request. Please try again.