nth_weekday 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe9148a95e6fccceea5df2e566aacef828d5ba8f45c1a3c1f5a617cb885fd83
4
- data.tar.gz: d1fd53f25234b13c9a83e6b23ec1e38ae7391cc57d25a3173f60e51bdef5cc14
3
+ metadata.gz: 17898431f95d95110a7939d73ecdfb186d6316cafb2e8fe193ed8d7ba4cf1f51
4
+ data.tar.gz: 52099f02ab6e904e90d234135f17d1782b43c5999bf86dbbf5878d7caa7951de
5
5
  SHA512:
6
- metadata.gz: 8fa5d703efbdb0227a22669f21f709bde1441f46d112a6aca5f5409f1fdf337850a7fdbdc984f90d856395c230fdded36c38cbd7f7805eb717bed5c77d42a87f
7
- data.tar.gz: 17049383e92ed5e877ba249bf4900484bd583b547d149264eb5fb8251ec14219dd45cffad33e2733f4ae91402fa16d92a942627c202bb3f1fb5528aef0dd0706
6
+ metadata.gz: 209ded1597fb87f51fc2752c1c768244ca8d5fda78ba6ecf1a52caf4583587e1d63121e953f8fe7fb38af227231934dd41c7597628930840cc1a6dae4e0000c4
7
+ data.tar.gz: 01260b0b375215f8dfb920f41deda20446273e9015b3542177bb79f117cbd7f38755beb813f03e19797023570a0adb5e6553048d070f3b8c56e1a80beb803672
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nth_weekday
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/nth_weekday.svg)](https://rubygems.org/gems/nth_weekday)
3
+ [![Gem Version](https://img.shields.io/gem/v/nth_weekday)](https://rubygems.org/gems/nth_weekday)
4
4
  [![Build Status](https://github.com/yusukehigasa/nth_weekday/actions/workflows/test.yml/badge.svg)](https://github.com/yusukehigasa/nth_weekday/actions)
5
5
 
6
6
  ---
@@ -30,6 +30,10 @@ gem 'nth_weekday'
30
30
  gem install nth_weekday
31
31
  ```
32
32
 
33
+ ## šŸ’» Requirements / å‹•ä½œē’°å¢ƒ
34
+
35
+ - Ruby 3.3.0仄上
36
+
33
37
  ## šŸš€ Usage / 使い方
34
38
 
35
39
  ```ruby
@@ -50,9 +54,18 @@ NthWeekday.get(year: 2025, month: 12, weekday: :fr, nth: -1)
50
54
  |--------------|--------|-------------------------------------------------------|
51
55
  | `year` | Integer| åÆ¾č±”å¹“ļ¼ˆä¾‹: 2025) |
52
56
  | `month` | Integer| 対豔月(1怜12) |
53
- | `weekday` | Symbol | åÆ¾č±”ę›œę—„ļ¼ˆä¾‹: `:mo`, `:tu`, `:we`, `:fr` など) |
57
+ | `weekday` | Symbol | åÆ¾č±”ę›œę—„ļ¼ˆ`:su`, `:mo`, `:tu`, `:we`, `:th`, `:fr`, `:sa`) |
54
58
  | `nth` | Integer| 第nā—Æę›œę—„ć€‚1怜5ć€ć¾ćŸćÆ `-1` ć§ć€Œęœ€å¾Œć®ā—Æę›œę—„ć€ć‚’ęŒ‡å®š |
55
59
 
60
+ ### ę›œę—„ć‚·ćƒ³ćƒœćƒ«äø€č¦§
61
+ - `:su` - ę—„ę›œę—„ (Sunday)
62
+ - `:mo` - ęœˆę›œę—„ (Monday)
63
+ - `:tu` - ē«ę›œę—„ (Tuesday)
64
+ - `:we` - ę°“ę›œę—„ (Wednesday)
65
+ - `:th` - ęœØę›œę—„ (Thursday)
66
+ - `:fr` - é‡‘ę›œę—„ (Friday)
67
+ - `:sa` - åœŸę›œę—„ (Saturday)
68
+
56
69
  ## 🧪 Example: 2025å¹“ć®å„ęœˆć®ē¬¬3ę°“ę›œę—„ć‚’å–å¾—
57
70
 
58
71
  ```ruby
@@ -68,9 +81,22 @@ end
68
81
  git clone https://github.com/yusukehigasa/nth_weekday.git
69
82
  cd nth_weekday
70
83
  bundle install
71
- rspec
84
+ bundle exec rspec # ćƒ†ć‚¹ćƒˆå®Ÿč”Œ
85
+ bundle exec rubocop # ć‚³ćƒ¼ćƒ‰ć‚¹ć‚æć‚¤ćƒ«ćƒć‚§ćƒƒć‚Æ
72
86
  ```
73
87
 
88
+ ć“ć®ćƒ—ćƒ­ć‚øć‚§ć‚Æćƒˆć§ćÆ [RuboCop](https://rubocop.org/) ć‚’ä½æē”Øć—ć¦ć‚³ćƒ¼ćƒ‰ć‚¹ć‚æć‚¤ćƒ«ć‚’äø€č²«ć—ć¦ē¶­ęŒć—ć¦ć„ć¾ć™ć€‚ć‚³ćƒ¼ćƒ‰å¤‰ę›“ę™‚ćÆ `bundle exec rubocop` ć§ć‚¹ć‚æć‚¤ćƒ«ćƒć‚§ćƒƒć‚Æć‚’å®Ÿč”Œć—ć¦ćć ć•ć„ć€‚
89
+
90
+ ## šŸ‘„ Contributing / 貢献
91
+
92
+ 1. Fork the repository
93
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
94
+ 3. Commit your changes (`git commit -am 'Add some amazing feature'`)
95
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
96
+ 5. Create a new Pull Request
97
+
98
+ ćƒć‚°å ±å‘Šć‚„ę©Ÿčƒ½č¦ęœ›ćÆ[GitHub Issues](https://github.com/yusukehigasa/nth_weekday/issues)ć«ćŠé”˜ć„ć—ć¾ć™ć€‚
99
+
74
100
  ## šŸ“„ License
75
101
 
76
102
  - MIT License
@@ -83,3 +109,4 @@ rspec
83
109
 
84
110
  - [RubyGems - nth_weekday](https://rubygems.org/gems/nth_weekday)
85
111
  - [GitHub Repository](https://github.com/yusukehigasa/nth_weekday)
112
+ - [Changelog](https://github.com/yusukehigasa/nth_weekday/blob/main/CHANGELOG.md)
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # nth_weekday の使用例
2
4
 
3
5
  require 'nth_weekday'
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'nth_weekday'
4
5
 
5
- puts "NthWeekday gem example"
6
- puts "======================="
6
+ puts 'NthWeekday gem example'
7
+ puts '======================='
7
8
 
8
9
  # 2025幓5月の第2ęœˆę›œę—„ć‚’å–å¾—
9
10
  monday = NthWeekday.get(year: 2025, month: 5, weekday: :mo, nth: 2)
data/lib/nth_weekday.rb CHANGED
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
 
3
5
  # NthWeekday module - Get specific weekdays (like 3rd Wednesday) from any year/month
4
6
  module NthWeekday
5
7
  # Mapping of weekday symbols to Date's wday values (0-6, Sunday is 0)
6
8
  WEEKDAY_MAP = {
7
- su: 0, # Sunday
8
- mo: 1, # Monday
9
- tu: 2, # Tuesday
10
- we: 3, # Wednesday
11
- th: 4, # Thursday
12
- fr: 5, # Friday
13
- sa: 6 # Saturday
9
+ su: 0, # Sunday
10
+ mo: 1, # Monday
11
+ tu: 2, # Tuesday
12
+ we: 3, # Wednesday
13
+ th: 4, # Thursday
14
+ fr: 5, # Friday
15
+ sa: 6 # Saturday
14
16
  }.freeze
15
17
 
16
18
  class << self
@@ -23,26 +25,26 @@ module NthWeekday
23
25
  # @raise [ArgumentError] If parameters are invalid
24
26
  def get(year:, month:, weekday:, nth:)
25
27
  validate_params(year, month, weekday, nth)
26
-
28
+
27
29
  wday = WEEKDAY_MAP[weekday.to_sym]
28
- raise ArgumentError, "Invalid weekday symbol" unless wday
29
-
30
+ raise ArgumentError, 'Invalid weekday symbol' unless wday
31
+
30
32
  first_day = Date.new(year, month, 1)
31
33
  last_day = first_day.next_month.prev_day
32
-
34
+
33
35
  days = (first_day..last_day).select { |date| date.wday == wday }
34
-
36
+
35
37
  if nth == -1
36
38
  days.last
37
39
  else
38
40
  days[nth - 1]
39
41
  end
40
42
  end
41
-
43
+
42
44
  private
43
-
44
- def validate_params(year, month, weekday, nth)
45
- raise ArgumentError, "Invalid year: #{year}" unless year.is_a?(Integer) && year > 0
45
+
46
+ def validate_params(year, month, _weekday, nth)
47
+ raise ArgumentError, "Invalid year: #{year}" unless year.is_a?(Integer) && year.positive?
46
48
  raise ArgumentError, "Invalid month: #{month}" unless month.is_a?(Integer) && month.between?(1, 12)
47
49
  raise ArgumentError, "Invalid nth: #{nth}" unless nth.is_a?(Integer) && (nth.between?(1, 5) || nth == -1)
48
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nth_weekday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Higasa
@@ -9,49 +9,7 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2025-05-10 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '13.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
12
+ dependencies: []
55
13
  description: A lightweight Ruby library to get dates like "3rd Wednesday" or "last
56
14
  Friday" from any given year and month. Rails-compatible and dependency-free.
57
15
  email: