https://github.com/sixarm/sixarm_ruby_week
SixArm.com » Ruby » Week model based on Ruby Date
https://github.com/sixarm/sixarm_ruby_week
date extensions gem ruby time week
Last synced: 12 months ago
JSON representation
SixArm.com » Ruby » Week model based on Ruby Date
- Host: GitHub
- URL: https://github.com/sixarm/sixarm_ruby_week
- Owner: SixArm
- License: other
- Created: 2012-02-25T10:34:06.000Z (over 14 years ago)
- Default Branch: main
- Last Pushed: 2025-04-14T09:21:30.000Z (about 1 year ago)
- Last Synced: 2025-04-14T10:31:14.409Z (about 1 year ago)
- Topics: date, extensions, gem, ruby, time, week
- Language: Ruby
- Homepage: http://sixarm.com
- Size: 526 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SixArm.com → Ruby →
Week model based on Ruby Date
[](http://badge.fury.io/rb/sixarm_ruby_week)
[](https://travis-ci.org/SixArm/sixarm_ruby_week)
[](https://codeclimate.com/github/SixArm/sixarm_ruby_week/maintainability)
* Git:
* Doc:
* Gem:
* Contact: Joel Parker Henderson,
* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).
## Introduction
This gem models a week, based on the built-in Ruby Date class.
For docs go to
Want to help? We're happy to get pull requests.
## Install
### Gem
To install this gem in your shell or terminal:
gem install sixarm_ruby_week
### Gemfile
To add this gem to your Gemfile:
gem 'sixarm_ruby_week'
### Require
To require the gem in your code:
require 'sixarm_ruby_week'
## Examples
Create:
week = Week.now
week = Week.new(Date.today)
week = Week.parse("2015-12-31")
Enumerable:
week.previous => seven days earlier
week.next => seven days later
Math:
week - 2 => two weeks earlier
week + 2 => two weeks later
First/Last, Begin/End, Start/Stop:
week.first_date => the first date of the week
week.last_date => the last date of the week
week.begin_date => first_date
week.end_date => last_date
week.start_date => first_date
week.stop_date => last_date
Range:
week.date_range => week.first_date..week.last_date
Collection:
week.include?(date) => true