Sha256: 1611efba967ed3dd859f4a0dda3ebda7130af0b8d7103f38c07bc3e0dcf2151b
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
Utility class for ranges of times (time periods). It's like Range, but has additional enumeration capabilities. See examples for the tasty stuff. Examples -------- period = TimeRange.new(1.year.ago, Time.now) Enumerate by days period.each(:day) { |time| puts time } Enumerate by weeks period.each(:week) { |time| puts time } (also years, months, hours, minutes and seconds) Enumerate by custom period period.each(42.seconds) { |time| puts time } +each+ Returns Enumerator object, so this is also possible (extra yummy): period.each(:month).map { |time| time.strftime('%B') } Supports all Enumerable interface: find, select, reject, inject, etc. Version compatibility -------- 0.3.0: Public repository along with the very first RubyGems gem 0.2.0: The Granulate class has been converted to a class method that returns a hash. Granulate was not easy to use because it returned an instance of 'Granulate'. This prevented clients from iterating through the result. 0.1.0: breaks compatibility with previous versions because it adds hours to the Granulate class. This means that in previous versions Granulate.rest contained time ranges that cannot be separated into days when granulating, but now it just contains ranges that cannot be separated into hours.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
3scale_time_range-0.3.0 | README.md |