An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# SixArm.com → Ruby →
Week model based on Ruby Date

[![Gem Version](https://badge.fury.io/rb/sixarm_ruby_week.svg)](http://badge.fury.io/rb/sixarm_ruby_week)
[![Build Status](https://travis-ci.org/SixArm/sixarm_ruby_week.png)](https://travis-ci.org/SixArm/sixarm_ruby_week)
[![Code Climate](https://api.codeclimate.com/v1/badges/f0cb0c2061882c919bd2/maintainability)](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