class PrayerTimes::CalculationMethod

Calculation method instances and logic is encapsulated here

Attributes

description[RW]
name[RW]
offsets[R]
settings[R]

Public Class Methods

default_settings() click to toggle source

Default settings

# File lib/prayer_times/calculation_method.rb, line 9
def self.default_settings
  {
    imsak:      '10 min',
    dhuhr:      '0 min',
    asr:        'Standard',
    maghrib:    '0 min',
    midnight:   'Standard',
    high_lats:  'NightMiddle'
  }
end
new(name,description,settings={}, offsets = {}) click to toggle source

Initializer @param [String] name @param [String] description @param [Hash] settings @option settings [String] :imsak @option settings [String] :fajr @option settings [String] :sunrise @option settings [String] :dhuhr @option settings [String] :asr Asr Juristic Methods:

'Standard':  Shafi`i, Maliki, Ja`fari and Hanbali,
'Hanafi':    Hanafi

@option settings [String] :sunset @option settings [String] :maghrib @option settings [String] :isha @option settings [String] :midnight Midnight Mode:

'Standard':     Mid Sunset to Sunrise,
'Jafari':       Mid Sunset to Fajr

@option settings [String] :high_lights Adjust Methods for Higher Latitudes:

'NightMiddle': middle of night,
'AngleBased':  angle/60th of night,
'OneSeventh':   1/7th of night,
'None'

@param [Hash] offsets @option offsets [String] :imsak @option offsets [String] :fajr @option offsets [String] :sunrise @option offsets [String] :dhuhr @option offsets [String] :asr @option offsets [String] :sunset @option offsets [String] :maghrib @option offsets [String] :isha @option offsets [String] :midnight

# File lib/prayer_times/calculation_method.rb, line 52
def initialize(name,description,settings={}, offsets = {})
  self.name = name
  self.description = description
  self.settings = settings
  self.offsets = offsets
end

Public Instance Methods

offsets=(offsets) click to toggle source

Sets times offsets @param [Hash] offsets Check the initializer

# File lib/prayer_times/calculation_method.rb, line 70
def offsets=(offsets)
  s = offsets.reject{|k,v| !(Constants.times_offsets.key?(k) and v.is_a?(Numeric))} rescue {}
  s[:sunset] = s[:maghrib] if s[:maghrib]
  @offsets = Constants.times_offsets.merge(s)
end
settings=(settings) click to toggle source

Sets times settings @param [Hash] settings Check the initializer

# File lib/prayer_times/calculation_method.rb, line 62
def settings=(settings)
  s = settings.reject{|k,v| !(Constants.times_names.key?(k))} rescue {}
  @settings = self.class.default_settings.merge(s)
end
to_s() click to toggle source

@return readable representation of this object

# File lib/prayer_times/calculation_method.rb, line 78
def to_s
  name
end