ZohaibAhmed / Quran

Ruby Gem for the Quran

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


The idea behind this gem was to provide a simple way for Ruby applications to access the contents of the Quran. Note, that this gem is still in its preliminary stages and there is still a lot of work to be done to provide more complex queries into the Quran.


gem install quran


Supported Languages:

  • English: 'en'
  • Arabic: 'ar'
  • Hindi: 'hi'
  • Urdu: 'ur'
require 'quran'
q = Quran.new ['en', 'ar']


q.get(5, 8)
=> {"chapter"=>5, "verse"=>8, "en"=>"O you who believe! Be upright for Allah, bearers of witness with justice, and let not hatred of a people incite you not to act equitably; act equitably, that is nearer to piety, and he careful of (your duty to) Allah; surely Allah is Aware of what you do.", "translator"=>"shakir"}


q.get_chapter(5, 8, lang='ar')
=> [{"chapter"=>112, "verse"=>1, "ar"=>"بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ قُلْ هُوَ ٱللَّهُ أَحَدٌ"}, {"chapter"=>112, "verse"=>2, "ar"=>"ٱللَّهُ ٱلصَّمَدُ"}, {"chapter"=>112, "verse"=>3, "ar"=>"لَمْ يَلِدْ وَلَمْ يُولَدْ"}, {"chapter"=>112, "verse"=>4, "ar"=>"وَلَمْ يَكُن لَّهُۥ كُفُوًا أَحَدٌۢ"}]


=> {:name=>"W-al-muḥṣanāt", :start_chapter=>4, :start_verse=>24, :end_chapter=>4, :end_verse=>147}


q.search('sin and aggression')
=> [{"chapter"=>5, "verse"=>2, "en"=>"O you who believe! do not violate the signs appointed by Allah nor the sacred month, nor (interfere with) the offerings, nor the sacrificial animals with garlands, nor those going to the sacred house seeking the grace and pleasure of their Lord; and when you are free from the obligations of the pilgrimage, then hunt, and let not hatred of a people-- because they hindered you from the Sacred Masjid-- incite you to exceed the limits, and help one another in goodness and piety, and do not help one another in sin and aggression; and be careful of (your duty to) Allah; surely Allah is severe in requiting (evil).", "translator"=>"shakir"}]

Command Line Tool

This gem ships with a command line tool. To get help, run:

quran -h


rake test


This would not have been possible without the Quran Text and Translations provided by http://tanzil.net. Looking for a Javascript alternative?


Ruby Gem for the Quran

License:MIT License


Language:Ruby 100.0%