🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

mmb-seasonal

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mmb-seasonal

bundlerRubyGems.org
Version
0.0.7
Version published
Maintainers
1
Created
Source

Create a calendar of date and time events, attach arbitrary objects to them and ask which objects are current at any point in time.

Uses the flexible time parsing of Time.parse to be easy to use and the timezone and DST handling of tzinfo.

Originally conceived for making web sites look and behave differently depending on the time of day or year.

Example (print holiday greetings):


require 'seasonal'

holidays = Seasonal::Calendar.new

holidays.push(Seasonal::Event.new('Merry Christmas', 'America/New_York',
  :on => 'dec 25'))
holidays.push(Seasonal::Event.new("April Fool's Day", 'America/New_York',
  :on => 'apr 1'))

holidays.going_on { |e| puts e }

Example (make text red between 9:00 and 10:00 am):


require 'seasonal'

colors = Seasonal::Calendar.new

colors.push(Seasonal::Event.new('#ff0000', 'America/New_York',
  :start => '9:00am', :end => '10:00am'))

color = colors.going_on(:or_if_none => '#000000')
puts "

test

"

Example (sale ends Jul 10):


require 'seasonal'

sales = Seasonal::Calendar.new

sales.push(Seasonal::Event.new('Everything on sale', 'America/New_York',
  :end => 'jul 10 2009'))

sales.going_on { |e| puts e }

FAQs

Package last updated on 11 Aug 2014

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