Project

dude_weak

0.0
No commit activity in last 3 years
No release in over 3 years
A simple Week class based on ActiveSupport Time Calculations
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0

Runtime

 Project Readme

DudeWeak

Get a Week object starting on that week's Monday, given a date object

Installation

Add this line to your application's Gemfile:

gem 'dude_weak'

And then execute:

$ bundle

Usage

# let(:today) { Time.parse('Jul 11, 2012') }
# let(:week)  { Week.new(today) }

week.monday #=> Time.parse('Jul 9, 2012')
week.number #=> 28
week.year   #=> 2012

Next Week

# let(:today) { Time.parse('Dec 29, 2012') }
# let(:week)  { Week.new(today) }

week.next.year   #=> 2013
week.next.number #=> 1

Previous Week

# let(:today) { Time.parse('Jan 2, 2012') }
# let(:week)  { Week.new(today) }

week.previous.year   #=> 2011
week.previous.number #=> 52

Days

# let(:today) { Time.parse('Jul 11, 2012') }
# let(:week)  { Week.new(today) }
    
days = week.days

days[0].dayname #=> 'Monday'
days[1].dayname #=> 'Tuesday'
days[2].dayname #=> 'Wednesday'
days[3].dayname #=> 'Thursday'
days[4].dayname #=> 'Friday'
days[5].dayname #=> 'Saturday'
days[6].dayname #=> 'Sunday'

Attach things to days

# let(:today) { Time.parse('Jul 11, 2012') }
# let(:week)  { Week.new(today) }

a = Thing.new
b = Something.new
c = Coolthing.new
    
week.days[0].things = [a, b, c]
    
week.days[0].things #=> [a, b, c]

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request