A beginners thrive for eloquence

14 views
Skip to first unread message

itabtabai

unread,
Jan 7, 2012, 9:11:26 PM1/7/12
to nokogiri-talk
I am a Ruby beginner who happens to be using it just because of
Nokogiri.
I have developed a code that does the conversion of digit glyphs from
Arabic to Arab-indic. The code does the job well. So I am not asking
for help to debug it.
I rather wondering if any of the advanced users on the list could give
a more eloquent code. I ask this because I think eloquence gives more
insight into Nokogir.

Here is the code:

=begin
iFile = File.open('01 copy.html', "r")
@doc = Nokogiri::HTML(iFile, nil, 'UTF-8')
iFile.close
@doc.css('section.pagenumber').each do |e|
a =
["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"] #
index represents arab-indic glyph
ainum =
""
# string to store arab-indic glyph
anum = e.content.match(/
\d{1,3}/) # extract arabic glyphs
anum.to_s.each_char {|c| ainum = ainum + a[c.to_i]} #
converting arabic glyph to arab-indic
e.content = "— #{ainum}
—" # finally assigning the
arabic-indic to the element
end
puts @doc.css('section.pagenumber')
=end

myliverhatesme

unread,
Jan 9, 2012, 9:48:37 PM1/9/12
to nokogiri-talk
If you want a chance of getting a response, please use pastie.org or
gist. Also provide the example file or at least tests.

itabtabai

unread,
Jan 12, 2012, 2:44:40 AM1/12/12
to nokogiri-talk
This is the paste.org link:
http://pastie.org/3170944

I am not sure how could I attach 10 MB files. But I've put a case in
the pastie code.
Reply all
Reply to author
Forward
0 new messages