qreki 0.0.3 → 0.0.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: d3c8c8a6930e72ce608f7f9971faa4577378374a
4
- data.tar.gz: fc9d775805f646e3334ea74dde4e741fcf99d3be
3
+ metadata.gz: 9bfe2c912114cb5bd3ce3b87093b63be6b126189
4
+ data.tar.gz: ef14bbf85a0a8fd94626900f87169ba83fe5ef4e
5
5
  SHA512:
6
- metadata.gz: 2995387ad8efb7317bbd0ed8f7cd63652c2644639e2929315d6eedc9c5d2c87c6b1edea0aecf12cb6776d3cd3f44a81124eb103e836652e77368f2f861bf9297
7
- data.tar.gz: 50988f79c2dcc15b521f296790f935055a2a09f9d373e50989260654ae53d66fcd6ba5d997a0684bf6a34b41e2c611053983a1c9f163b4ce0211a4a2a8ea3344
6
+ metadata.gz: 3bf1e9f58fe719034b981084bef470298a8dacbfe1c186aa36d1d9138bc351413d724a108789d8bf7eab8df9c354a1b0ab2658e15a06c42f7ccb99426c981fc5
7
+ data.tar.gz: 579e1064028e24c0f0d980dbc811a8dbde3986b32b5b8091fb8bd611f896d1116827a82b6f84b625f57b5e2b7fbe73abd56a276870e44c00c6a917faacc194e8
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ vendor
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rspec', '~> 3.0'
4
+
3
5
  # Specify your gem's dependencies in qreki.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -18,6 +18,10 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ >> require 'qreki'
22
+
23
+ Calc qreki "旧暦" as:
24
+
21
25
  >> qreki = Qreki.calc(2013,11,7)
22
26
  >> qreki.year # 2013
23
27
  >> qreki.uruu # false
@@ -26,6 +30,20 @@ Or install it yourself as:
26
30
  >> qreki.rokuyou # "友引"
27
31
  >> qreki.sekki # "立冬"
28
32
 
33
+ Calc shunbun "春分の日" as:
34
+
35
+ >> sreki = Qreki.shunbun(2014)
36
+ >> sreki.year # 2014
37
+ >> sreki.month # 3
38
+ >> sreki.day # 21
39
+
40
+ Calc shuubun "秋分の日" as:
41
+
42
+ >> sreki = Qreki.shuubun(2014)
43
+ >> sreki.year # 2014
44
+ >> sreki.month # 9
45
+ >> sreki.day # 23
46
+
29
47
  ## Contributing
30
48
 
31
49
  1. Fork it
@@ -9,6 +9,10 @@ require "date"
9
9
 
10
10
  module Qreki
11
11
 
12
+ class Srk
13
+ attr_accessor :year, :month, :day
14
+ end
15
+
12
16
  class Qrk
13
17
  attr_accessor :year, :uruu, :month, :day, :rokuyou, :sekki
14
18
  end
@@ -30,7 +34,7 @@ module Qreki
30
34
  # q.sekki : 二十四節気
31
35
  #=========================================================================
32
36
  def self.calc(year, month, day)
33
- return calc_from_date(Date.new(year, month, day))
37
+ calc_from_date(Date.new(year, month, day))
34
38
  end
35
39
 
36
40
  def self.calc_from_date(tm)
@@ -42,7 +46,7 @@ module Qreki
42
46
  qreki.day = array[3]
43
47
  qreki.rokuyou = rokuyou(tm.year, tm.month, tm.day)
44
48
  qreki.sekki = sekki(tm.year, tm.month, tm.day)
45
- return qreki
49
+ qreki
46
50
  end
47
51
 
48
52
  # =========================================================================
@@ -189,7 +193,7 @@ module Qreki
189
193
  kyureki[0] -= 1
190
194
  end
191
195
 
192
- return [kyureki[0], kyureki[1], kyureki[2], kyureki[3]]
196
+ [kyureki[0], kyureki[1], kyureki[2], kyureki[3]]
193
197
  end
194
198
 
195
199
  # =========================================================================
@@ -271,7 +275,7 @@ module Qreki
271
275
  # 戻り値の作成
272
276
  # 時刻引数を合成し、戻り値(JSTユリウス日)とする
273
277
  # -----------------------------------------------------------------------
274
- return tm2 + tm1 - $tz
278
+ tm2 + tm1 - $tz
275
279
  end
276
280
 
277
281
  # =========================================================================
@@ -381,7 +385,7 @@ module Qreki
381
385
  # 戻り値の作成
382
386
  # 時刻引数を合成し、戻り値(ユリウス日)とする
383
387
  # -----------------------------------------------------------------------
384
- return tm2 + tm1 - $tz
388
+ tm2 + tm1 - $tz
385
389
  end
386
390
 
387
391
  # =========================================================================
@@ -426,7 +430,7 @@ module Qreki
426
430
  ang = normalization_angle( ang + 280.4659 )
427
431
  th = normalization_angle( th + ang )
428
432
 
429
- return th
433
+ th
430
434
  end
431
435
 
432
436
  # =========================================================================
@@ -505,7 +509,7 @@ module Qreki
505
509
  ang = normalization_angle( ang + 218.3162 )
506
510
  th = normalization_angle( th + ang )
507
511
 
508
- return th
512
+ th
509
513
  end
510
514
 
511
515
  #=========================================================================
@@ -534,7 +538,7 @@ module Qreki
534
538
 
535
539
  jd += t
536
540
 
537
- return jd
541
+ jd
538
542
  end
539
543
 
540
544
  #=========================================================================
@@ -577,7 +581,7 @@ module Qreki
577
581
  time[4] = ( (tm - 3600.0 * time[3] ) / 60.0 ).to_i
578
582
  time[5] = ( tm - 3600.0 * time[3] - 60 * time[4] ).to_i
579
583
 
580
- return time
584
+ time
581
585
  end
582
586
 
583
587
  #=========================================================================
@@ -591,7 +595,7 @@ module Qreki
591
595
 
592
596
  q_yaer, uruu, q_mon, q_day = calc_kyureki(year, mon, day)
593
597
 
594
- return rokuyou[ (q_mon + q_day) % 6 ]
598
+ rokuyou[ (q_mon + q_day) % 6 ]
595
599
  end
596
600
 
597
601
  #=========================================================================
@@ -639,4 +643,24 @@ module Qreki
639
643
  return ''
640
644
  end
641
645
  end
646
+
647
+ def self.shunbun(year)
648
+ day = (20.8431 + 0.242194 * ( year - 1980 ) - ( year - 1980 ) / 4).to_i
649
+
650
+ sreki = Srk.new
651
+ sreki.year = year
652
+ sreki.month = 3
653
+ sreki.day = day
654
+ sreki
655
+ end
656
+
657
+ def self.shuubun(year)
658
+ day = (23.2488 + 0.242194 * ( year - 1980 ) - ( year - 1980 ) / 4).to_i
659
+
660
+ sreki = Srk.new
661
+ sreki.year = year
662
+ sreki.month = 9
663
+ sreki.day = day
664
+ sreki
665
+ end
642
666
  end
@@ -1,3 +1,3 @@
1
1
  module Qreki
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -11,41 +11,71 @@ describe Qreki do
11
11
 
12
12
  it "should calc eql 2013,11,1 => 2013,false,9,28 赤口" do
13
13
  @q = Qreki.calc(2013,11,1)
14
- @q.year.should eql 2013
15
- @q.uruu.should eql false
16
- @q.month.should eql 9
17
- @q.day.should eql 28
18
- @q.rokuyou.should eql "赤口"
19
- @q.sekki.should eql ""
14
+ expect(@q.year).to eql 2013
15
+ expect(@q.uruu).to eql false
16
+ expect(@q.month).to eql 9
17
+ expect(@q.day).to eql 28
18
+ expect(@q.rokuyou).to eql "赤口"
19
+ expect(@q.sekki).to eql ""
20
20
  end
21
21
 
22
22
  it "should calc eql 2014,11,1 => 2014,true, 9,9 大安" do
23
23
  @q = Qreki.calc(2014,11,1)
24
- @q.year.should eql 2014
25
- @q.uruu.should eql true
26
- @q.month.should eql 9
27
- @q.day.should eql 9
28
- @q.rokuyou.should eql "大安"
29
- @q.sekki.should eql ""
24
+ expect(@q.year).to eql 2014
25
+ expect(@q.uruu).to eql true
26
+ expect(@q.month).to eql 9
27
+ expect(@q.day).to eql 9
28
+ expect(@q.rokuyou).to eql "大安"
29
+ expect(@q.sekki).to eql ""
30
30
  end
31
31
 
32
32
  it "should calc eql 2014,3,30 => 2014,false,2,30" do
33
33
  @q = Qreki.calc(2014,3,30) # => 2014,false,2,30
34
- @q.year.should eql 2014
35
- @q.uruu.should eql false
36
- @q.month.should eql 2
37
- @q.day.should eql 30
38
- @q.rokuyou.should eql "先勝"
39
- @q.sekki.should eql ""
34
+ expect(@q.year).to eql 2014
35
+ expect(@q.uruu).to eql false
36
+ expect(@q.month).to eql 2
37
+ expect(@q.day).to eql 30
38
+ expect(@q.rokuyou).to eql "先勝"
39
+ expect(@q.sekki).to eql ""
40
40
  end
41
41
 
42
42
  it "should calc_from_date eql 2013,11,7 => 2013,false,10,5" do
43
43
  @q = Qreki.calc_from_date(Date.new(2013,11,7))
44
- @q.year.should eql 2013
45
- @q.uruu.should eql false
46
- @q.month.should eql 10
47
- @q.day.should eql 5
48
- @q.rokuyou.should eql "友引"
49
- @q.sekki.should eql "立冬"
50
- end
51
- end
44
+ expect(@q.year).to eql 2013
45
+ expect(@q.uruu).to eql false
46
+ expect(@q.month).to eql 10
47
+ expect(@q.day).to eql 5
48
+ expect(@q.rokuyou).to eql "友引"
49
+ expect(@q.sekki).to eql "立冬"
50
+ end
51
+
52
+
53
+ it "should shunbun eql 2014 => 2014,3,21" do
54
+ @q = Qreki.shunbun(2014) # => 2014,3,21
55
+ expect(@q.year).to eql 2014
56
+ expect(@q.month).to eql 3
57
+ expect(@q.day).to eql 21
58
+ end
59
+
60
+ it "should shunbun eql 2030 => 2030,3,20" do
61
+ @q = Qreki.shunbun(2030) # => 2030,3,20
62
+ expect(@q.year).to eql 2030
63
+ expect(@q.month).to eql 3
64
+ expect(@q.day).to eql 20
65
+ end
66
+
67
+
68
+ it "should shuubun eql 2014 => 2014,9,23" do
69
+ @q = Qreki.shuubun(2014) # => 2014,9,23
70
+ expect(@q.year).to eql 2014
71
+ expect(@q.month).to eql 9
72
+ expect(@q.day).to eql 23
73
+ end
74
+
75
+ it "should shuubun eql 2030 => 2030,9,23" do
76
+ @q = Qreki.shuubun(2030) # => 2030,9,23
77
+ expect(@q.year).to eql 2030
78
+ expect(@q.month).to eql 9
79
+ expect(@q.day).to eql 23
80
+ end
81
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qreki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Ozawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-14 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.0.3
78
+ rubygems_version: 2.2.2
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: qreki