holidays_in_month 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32194ceaa55090daa2d8e39a007c60ab825e9302
4
- data.tar.gz: 8aa28cdac1d28f10806a16e5c4a2596b05ef09e4
3
+ metadata.gz: 4dfaf63b472e085d5685d9d3b9da017ca71183ab
4
+ data.tar.gz: f2d4350613a77c4d87f044f1355caacf499dc44d
5
5
  SHA512:
6
- metadata.gz: 3e25c93bcb52b84372b577b39d06d72ad9ceb5bee602f78a20a7182779ac0732ee8c501755b6b738147d491d2b8090211c2ba3c12dbe94888cd8735b9198ceb4
7
- data.tar.gz: c632be6dc22b691f19a2dd0a78729d626f18ca40d52c814ef46a4799532b472c8363dd31265e6293d00f1d36b8cbefbcabb50a64012c557b57c47392fd66ddc3
6
+ metadata.gz: f291c7258eb610b897a305b24694e7aeb6e833155eafbc477e14408fb41d65601434152f3be758ce3c836ef7910631c1df31ee13934933ab52c4614133c86b4d
7
+ data.tar.gz: c11c108761809b35b87693219721173562150abfb5ebeb1e03b2a849b86d715f7da0e08349ed1849d153f9cb74c60ffa3a2a121b0d12401f2b4b50e6e16ac68a
data/README.md CHANGED
@@ -2,46 +2,30 @@
2
2
 
3
3
  This gem is return holidays(Saturday, Sunday, National) of month in Japan.
4
4
 
5
- ```ruby
6
- obj.get_in_month(2016, 1)
7
- => ["2016-1-2", "2016-1-3", "2016-1-9", "2016-1-10", "2016-1-16", "2016-1-17",
5
+ ## Usage
6
+
7
+ ```ruby
8
+ Holiday.new.in_month(2016, 1)
9
+ => ["2016-1-2", "2016-1-3", "2016-1-9", "2016-1-10", "2016-1-16", "2016-1-17",
8
10
  "2016-1-23", "2016-1-24", "2016-1-30", "2016-1-31", {"2016-01-01"=>"元日", "2016-01-11"=>"成人の日"}]
9
- ```
11
+ ```
10
12
 
11
13
  ## Installation
12
14
 
13
- Add this line to your application's Gemfile:
14
-
15
- ```ruby
16
- gem 'holidays_in_month'
17
- ```
15
+ Add this line to your application's Gemfile:
18
16
 
19
- And then execute:
17
+ ```ruby
18
+ gem 'holidays_in_month'
19
+ ```
20
20
 
21
- $ bundle install
21
+ And then execute:
22
22
 
23
- Or install it yourself as:
23
+ $ bundle install
24
24
 
25
- $ gem install holidays_in_month
26
-
27
- ## Usage
25
+ Or install it yourself as:
28
26
 
29
- Add this line to your application's Model or Controller:
30
-
31
- ```ruby
32
- holidays = JP::Holidays.new
33
- holidays.get_in_month(year, month)
34
- ```
35
-
36
- example:
37
-
38
- ```ruby
39
- @holidays = JP::Holidays.new
40
- @holidays.get_in_month(2016, 1)
41
- @holidays => ["2016-1-2", "2016-1-3", "2016-1-9", "2016-1-10", "2016-1-16", "2016-1-17",
42
- "2016-1-23", "2016-1-24", "2016-1-30", "2016-1-31", {"2016-01-01"=>"元日", "2016-01-11"=>"成人の日"}]
43
- ```
27
+ $ gem install holidays_in_month
44
28
 
45
29
  ## License
46
30
 
47
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
31
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module Holidays
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -1,40 +1,36 @@
1
- require 'holidays_in_month/version'
2
- require 'active_support'
3
- require 'active_support/time'
4
- require 'time'
5
- require 'yaml'
1
+ class Holiday
2
+ def initialize
3
+ @nationaldays = {}
4
+ @holidays = []
5
+ end
6
6
 
7
- module JP
8
- class Holiday
9
- def get_in_month(year, month)
10
- init
11
- #休日に祝日を追加
12
- holidays(year, month) << nationaldays.select { |n| n.match(/#{year}-#{"%02d" % month}-*/) }
13
- end
7
+ def in_month(year, month)
8
+ holidays(year, month) << nationaldays.select { |n| n.match(/#{year}-#{"%02d" % month}-*/) }
9
+ end
14
10
 
15
- private
11
+ private
16
12
 
17
- def init
18
- @nationaldays = {}
19
- @holidays = []
20
- end
21
-
22
- def nationaldays
23
- yaml = YAML.load_file(File.expand_path('./../../holidays.yml', __FILE__))
24
- yaml.each do |date, name|
25
- @nationaldays.store(date.strftime("%Y-%m-%d"), name)
26
- end
27
- @nationaldays
13
+ def nationaldays
14
+ yaml = YAML.load_file(File.expand_path('./../../holidays.yml', __FILE__))
15
+ yaml.each do |date, name|
16
+ @nationaldays.store(date.strftime("%Y-%m-%d"), name)
28
17
  end
18
+ @nationaldays
19
+ end
29
20
 
30
- def holidays(year, month)
31
- num_days_of_month = Date.new(year, month).end_of_month.day
21
+ def holidays(year, month)
22
+ num_days_of_month = Date.new(year, month).end_of_month.day
32
23
 
33
- 1.upto(num_days_of_month) do |day|
34
- wday = Date.new(year, month, day).wday
35
- @holidays << "%04d-%02d-%02d" % [year, month, day] if wday == 6 || wday == 0
36
- end
37
- @holidays
24
+ 1.upto(num_days_of_month) do |day|
25
+ wday = Date.new(year, month, day).wday
26
+ @holidays << "%04d-%02d-%02d" % [year, month, day] if wday == 6 || wday == 0
38
27
  end
28
+ @holidays
39
29
  end
40
30
  end
31
+
32
+ require 'holidays_in_month/version'
33
+ require 'active_support'
34
+ require 'active_support/time'
35
+ require 'time'
36
+ require 'yaml'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holidays_in_month
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Hasada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-21 00:00:00.000000000 Z
11
+ date: 2016-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport