🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

3scale_time_range

Package Overview
Dependencies
Maintainers
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

3scale_time_range

0.3.0
Rubygems
Version published
Maintainers
5
Created
Source

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.

FAQs

Package last updated on 09 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts