lib/prayer_times/setters.rb in prayer_times-0.1.1 vs lib/prayer_times/setters.rb in prayer_times-0.1.2

- old
+ new

@@ -1,31 +1,31 @@ # encoding: UTF-8 module PrayerTimes - # General setters + # General setters module Setters - + # Sets iterations c # @param [Integer] num # 0 < num < 6 def iterations_count=(num) @iterations_count = if (Constants.accepted_iterations_count_range).include?(num) num - else - const_class.iterations_count - end + else + const_class.iterations_count + end end - + # Sets time format # @param [String] format # '24h': 24-hour format, # '12h': 12-hour format, # '12hNS': 12-hour format with no suffix, # 'Float': floating point number def time_format=(format) @time_format = if Constants.accepted_time_formats.include?(format) format - else + else const_class.time_format end end # Sets the invalid time replacement string @@ -50,23 +50,24 @@ # Sets times offsets # @param [Hash] offsets def times_offsets=(offsets) s = offsets.reject{|k,v| !(const_class.times_offsets.key?(k) and v.is_a?(Numeric))} rescue {} - @times_offsets = const_class.times_offsets.merge(s) + @times_offsets = const_class.times_offsets.merge(s) end # Sets calculation method and the corresponding settings # @param [String] calc_method the method name def calculation_method=(calc_method) @calculation_method = if PrayerTimes.calculation_methods.key?(calc_method) const_class.calculation_methods[calc_method] else PrayerTimes.calculation_method end - end - + end + def const_class #:nodoc: - raise "Please override this method" + raise NotImplementedError, + "You must implement #const_class to define which class to get the default attributes from" end end -end \ No newline at end of file +end