Sha256: c71d974ec1c3d808c9d2f46bda02f4b61cb20f5eb5fa0d8009487f6aebd44fbc

Contents?: true

Size: 528 Bytes

Versions: 9

Compression:

Stored size: 528 Bytes

Contents

module Prosperity
  class Period < Struct.new(:db_strf_str, :ruby_strf_str, :duration, :floor_date, :ceil_date)
    def each_period(start_time, end_time)
      start_time = actual_start_time(start_time)
      end_time = actual_end_time(end_time) + 1
      while start_time <= end_time
        yield start_time
        start_time += duration
      end
    end

    def actual_start_time(start_time)
      floor_date.call(start_time)
    end

    def actual_end_time(end_time)
      ceil_date.call(end_time) + 1
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
prosperity-0.0.11 lib/prosperity/period.rb
prosperity-0.0.10 lib/prosperity/period.rb
prosperity-0.0.9 lib/prosperity/period.rb
prosperity-0.0.8 lib/prosperity/period.rb
prosperity-0.0.7 lib/prosperity/period.rb
prosperity-0.0.6 lib/prosperity/period.rb
prosperity-0.0.5 lib/prosperity/period.rb
prosperity-0.0.4 lib/prosperity/period.rb
prosperity-0.0.3 lib/prosperity/period.rb