Class: PrayerTimes::CalculationMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/prayer_times/calculation_method.rb

Overview

Calculation method instances and logic is encapsulated here

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, settings = {}, offsets = {}) ⇒ CalculationMethod

Initializer

Parameters:

  • name (String)
  • description (String)
  • settings (Hash) (defaults to: {})
  • offsets (Hash) (defaults to: {})

Options Hash (settings):

  • :imsak (String)
  • :fajr (String)
  • :sunrise (String)
  • :dhuhr (String)
  • :asr (String)

    Asr Juristic Methods: ‘Standard’: Shafi`i, Maliki, Ja`fari and Hanbali, ‘Hanafi’: Hanafi

  • :sunset (String)
  • :maghrib (String)
  • :isha (String)
  • :midnight (String)

    Midnight Mode: ‘Standard’: Mid Sunset to Sunrise, ‘Jafari’: Mid Sunset to Fajr

  • :high_lights (String)

    Adjust Methods for Higher Latitudes: ‘NightMiddle’: middle of night, ‘AngleBased’: angle/60th of night, ‘OneSeventh’: 1/7th of night, ‘None’

Options Hash (offsets):

  • :imsak (String)
  • :fajr (String)
  • :sunrise (String)
  • :dhuhr (String)
  • :asr (String)
  • :sunset (String)
  • :maghrib (String)
  • :isha (String)
  • :midnight (String)


52
53
54
55
56
57
# 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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/prayer_times/calculation_method.rb', line 5

def description
  @description
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/prayer_times/calculation_method.rb', line 5

def name
  @name
end

#offsetsObject

Returns the value of attribute offsets.



5
6
7
# File 'lib/prayer_times/calculation_method.rb', line 5

def offsets
  @offsets
end

#settingsObject

Returns the value of attribute settings.



5
6
7
# File 'lib/prayer_times/calculation_method.rb', line 5

def settings
  @settings
end

Class Method Details

.default_settingsObject

Default settings



9
10
11
12
13
14
15
16
17
18
# 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

Instance Method Details

#to_sObject

Returns readable representation of this object.

Returns:

  • readable representation of this object



77
78
79
# File 'lib/prayer_times/calculation_method.rb', line 77

def to_s
  name
end