Skip to content

Commit

Permalink
Remove #[] method from Transliterator::Base instances
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeric committed Apr 6, 2012
1 parent 84a13b3 commit 770e4eb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
6 changes: 1 addition & 5 deletions lib/transliterator/base.rb
Expand Up @@ -61,10 +61,6 @@ def initialize
end end
end end


def [](codepoint)
approximations[codepoint] || codepoint
end

# Transliterate a given string's UTF-8 characters to their ASCII equivalants. # Transliterate a given string's UTF-8 characters to their ASCII equivalants.
# #
# transliterator = Transliterator::Base.instance # transliterator = Transliterator::Base.instance
Expand All @@ -73,7 +69,7 @@ def [](codepoint)
# @return [String] The transliterated string # @return [String] The transliterated string
def transliterate(string) def transliterate(string)
string.unpack("U*") string.unpack("U*")
.map { |char| self[char] } .map { |codepoint| approximations[codepoint] || codepoint }
.flatten .flatten
.pack("U*") .pack("U*")
end end
Expand Down
10 changes: 0 additions & 10 deletions spec/transliterator/base_spec.rb
Expand Up @@ -24,16 +24,6 @@
end end
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 describe '#transliterate' do
it 'transliterates math related characters' do it 'transliterates math related characters' do
subject.transliterate("5 × 10 ÷ 2 ‐ 5 = 20").should == '5 x 10 / 2 - 5 = 20' subject.transliterate("5 × 10 ÷ 2 ‐ 5 = 20").should == '5 x 10 / 2 - 5 = 20'
Expand Down

0 comments on commit 770e4eb

Please sign in to comment.