lib/saulabs/reportable/reporting_period.rb in reportable-1.0.3 vs lib/saulabs/reportable/reporting_period.rb in reportable-1.1.0

- old
+ new

@@ -69,21 +69,20 @@ # @return [Saulabs::Reportable::ReportingPeriod] # the reporting period for the {Saulabs::Reportable::Grouping} as parsed from the db string # def self.from_db_string(grouping, db_string) parts = grouping.date_parts_from_db_string(db_string) - result = case grouping.identifier + case grouping.identifier when :hour self.new(grouping, DateTime.new(parts[0], parts[1], parts[2], parts[3], 0, 0)) when :day self.new(grouping, Date.new(parts[0], parts[1], parts[2])) when :week self.new(grouping, Date.commercial(parts[0], parts[1], 1)) when :month self.new(grouping, Date.new(parts[0], parts[1], 1)) end - result end # Gets the next reporting period. # # @return [Saulabs::Reportable::ReportingPeriod] @@ -110,10 +109,10 @@ # @return [Boolean] # true if +other+ is equal to the current reporting period, false otherwise # def ==(other) if other.is_a?(Saulabs::Reportable::ReportingPeriod) - @date_time.to_s == other.date_time.to_s && @grouping.identifier.to_s == other.grouping.identifier.to_s + @date_time == other.date_time && @grouping.identifier == other.grouping.identifier elsif other.is_a?(Time) || other.is_a?(DateTime) @date_time == parse_date_time(other) else raise ArgumentError.new("Can only compare instances of #{self.class.name}") end