Home - Startappz/prayer_times GitHub Wiki
===
Flexible and configurable calculation for Muslim prayers times.
Installation
Add this line to your application's Gemfile:
gem 'prayer_times'
And then execute:
$ bundle
Or install it yourself as:
$ gem install prayer_times
Usage
Baisc usage
require 'prayer_times'
pt = PrayerTimes.new("Makkah")
times = pt.get_times(Date.today(), [31,36], 3)
puts times.inspect
Global configuration
You can have a global configuration through the PrayerTimes module:
require 'prayer_times'
PrayerTimes.time_format = '12h'
PrayerTimes.time_suffixes = {:am => 'صباحا', :pm => 'مساءا'}
# and others...
Adding more methods
There are several methods that are shiped with this gem by default. You can list, add new or update existing ones.
PrayerTimes.calculation_methods
PrayerTimes.calculation_methods.names
PrayerTimes.calculation_methods.add("Test", "Testing method", fajr: 16.5, asr: 'Hanafi', isha: '80 min')
new_method = PrayerTimes.calculation_methods["Test"]
new_method.description = "new description"
new_method.settings = {fajr: 19.5, isha: '33 min'}
PrayerTimes.calculation_methods.delete("Test")
Instance configuration
As with the global configuration, you can set the configuration on the object level:
require 'prayer_times'
PrayerTimes.time_format = '12h'
PrayerTimes.time_suffixes = {am: 'صباحا', pm: 'مساءا'}
options = {
time_format: '12h',
time_suffixes: {am: => 'صباحا', pm: 'مساءا'}
# and others...
}
pt = PrayerTimes.new("Makkah", options)
Help
Your help is appreciated, specially in adjusting the calculation methods and making them more accurate. Your contribution is welcome.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request