when_exe 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.ja.txt +8 -21
  3. data/LICENSE.txt +5 -27
  4. data/README.md +8 -63
  5. data/bin/make_ttl.rb +3 -2
  6. data/bin/make_ttl.rb.config +3 -3
  7. data/lib/when_exe.rb +8 -3
  8. data/lib/when_exe/basictypes.rb +1 -2
  9. data/lib/when_exe/calendarnote.rb +9 -5
  10. data/lib/when_exe/calendartypes.rb +4 -4
  11. data/lib/when_exe/coordinates.rb +14 -18
  12. data/lib/when_exe/ephemeris.rb +5 -6
  13. data/lib/when_exe/events.rb +7 -7
  14. data/lib/when_exe/google_api.rb +26 -31
  15. data/lib/when_exe/icalendar.rb +8 -8
  16. data/lib/when_exe/inspect.rb +3 -3
  17. data/lib/when_exe/linkeddata.rb +10 -2
  18. data/lib/when_exe/locales/locale.rb +2 -2
  19. data/lib/when_exe/parts/enumerator.rb +3 -3
  20. data/lib/when_exe/parts/geometric_complex.rb +2 -2
  21. data/lib/when_exe/parts/resource.rb +2 -2
  22. data/lib/when_exe/parts/timezone.rb +17 -29
  23. data/lib/when_exe/region/balinese.rb +5 -3
  24. data/lib/when_exe/region/chinese.rb +25 -3
  25. data/lib/when_exe/region/chinese/twins.rb +128 -5
  26. data/lib/when_exe/region/dee.rb +4 -4
  27. data/lib/when_exe/region/geologicalage.rb +137 -126
  28. data/lib/when_exe/region/hanke_henry.rb +4 -4
  29. data/lib/when_exe/region/indian.rb +73 -4
  30. data/lib/when_exe/region/international_fixed.rb +3 -3
  31. data/lib/when_exe/region/japanese.rb +9 -5
  32. data/lib/when_exe/region/japanese/epochs.rb +8 -4
  33. data/lib/when_exe/region/japanese/notes.rb +25 -7
  34. data/lib/when_exe/region/japanese/residues.rb +32 -10
  35. data/lib/when_exe/region/japanese/weeks.rb +7 -7
  36. data/lib/when_exe/region/korean.rb +17 -17
  37. data/lib/when_exe/region/saudi_arabian.rb +57 -0
  38. data/lib/when_exe/region/world.rb +3 -3
  39. data/lib/when_exe/timestandard.rb +7 -5
  40. data/lib/when_exe/tmobjects.rb +2 -2
  41. data/lib/when_exe/tmposition.rb +6 -4
  42. data/lib/when_exe/tmreference.rb +3 -3
  43. data/lib/when_exe/version.rb +3 -3
  44. data/test/events/example-datasets +0 -1
  45. data/test/events/japanese-holiday.csv +23 -6
  46. data/test/events/japanese-holiday.ttl +321 -151
  47. data/test/test/basictypes.rb +2 -2
  48. data/test/test/calendarnote.rb +2 -2
  49. data/test/test/coordinates.rb +6 -4
  50. data/test/test/ephemeris.rb +2 -2
  51. data/test/test/google_api.rb +45 -32
  52. data/test/test/inspect.rb +2 -2
  53. data/test/test/parts.rb +5 -5
  54. data/test/test/region/christian.rb +7 -7
  55. data/test/test/region/indian.rb +14 -1
  56. data/test/test/region/islamic.rb +11 -1
  57. data/test/test/region/japanese.rb +3 -3
  58. data/test/test/region/m17n.rb +2 -2
  59. data/test/test/region/reforms.rb +2 -2
  60. data/test/test/tmposition.rb +7 -7
  61. metadata +7 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a70f4c1554b425044499c3ed9055af1716bd6583
4
- data.tar.gz: 494d431688613d512807d12a7cf2d980cc0f8938
2
+ SHA256:
3
+ metadata.gz: e033cac66a5dfbe35abf7e1ded44ddd7775c8cb6c523d9942261e863b45be2ea
4
+ data.tar.gz: 445721eaa7db250aa97e4e95c12f173195cd229119fc60ff7c77dec0b8dba195
5
5
  SHA512:
6
- metadata.gz: dcc18438e7fb48199d6857d38360046ab94983b85bde2830179713d4c493782934181ad84fc88992396c8370100f83364e677a3274eb57bf87195426ca8898b8
7
- data.tar.gz: 0b6c58602fe5e9f49017e54ead7652b1076cd2e7e7bf7881c0d40e512661f1258df70fb8f0bc36cebcb1e7be820514222e0c5bd35f6440142024e2075c53f441
6
+ metadata.gz: 33cf89beed3b1194a9eeb47ad6b7f58fc1feebedabb2353e72a906ad4888b8ea4d6f6edb3abdb872f197df55aca0cf84899e6c5c52aedb4c244559fcb1919011
7
+ data.tar.gz: b05ba8ebd6b49ba2b70e15dd3a84b877765f45a1f0afd654b6ed27cc755d809b37a6cb583e762a74ebd9c688219755cf086dfbf56ba95e14c5e13f3b9318ce24
data/LICENSE.ja.txt CHANGED
@@ -1,25 +1,12 @@
1
- When.exe: A multicultural and multilingualized calendar library
1
+ The MIT License (MIT)
2
2
 
3
- 本プログラムの著作権は須賀隆 <suchowan@box.email.ne.jp> にあります。
3
+ Copyright (c) 2011 Takashi SUGA <suchowan@box.email.ne.jp>.
4
4
 
5
- 本プログラムは,下記の条件で使用できます.
5
+ 以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。
6
+ これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
6
7
 
7
- 1. 必ず、著作権表示や免責事項を含めて、制限なく自由に複製できます.
8
+ 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
8
9
 
9
- 2. 以下の条件のいずれかを満たす時に本プログラムを自由に変更できます.
10
-
11
- (a) 変更した本プログラムを自分だけで使う.
12
-
13
- (b) その他の変更条件を作者と書面により合意する.
14
-
15
- 3. 本プログラム,変更した本プログラム及び本プログラムから生成した実行形式は,
16
- 作者との書面による合意がなければ配布できません.
17
-
18
- 4. 他のプログラムとの併合はいかなる目的であれ自由です.
19
-
20
- 5. 本プログラムへの入力となるデータおよび本プログラムからの出力の権利は
21
- 本プログラムの作者ではなく,それぞれの入出力を生成した人に属します.
22
-
23
- 6. 本プログラムは無保証です.作者は本プログラムをサポートする意志はありますが,
24
- プログラム自身のバグあるいは本プログラムの実行などから発生するいかなる損害に
25
- 対しても責任を持ちません.
10
+ ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。
11
+ ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
12
+ 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
data/LICENSE.txt CHANGED
@@ -1,31 +1,9 @@
1
- When.exe: A multicultural and multilingualized calendar library
1
+ The MIT License (MIT)
2
2
 
3
- This library is copyrighted free software by Takashi SUGA <suchowan@box.email.ne.jp>.
3
+ Copyright (c) 2011 Takashi SUGA <suchowan@box.email.ne.jp>.
4
4
 
5
- You can use and/or modify the software under the conditions below:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
7
- 1. You may make verbatim copies of the software without restriction, provided
8
- that you duplicate all of the original copyright notices and associated
9
- disclaimers.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
8
 
11
- 2. You may modify your copy of the software in any way, provided that
12
- you do at least ONE of the following:
13
-
14
- a) place your modifications in your private domain.
15
-
16
- b) make other written arrangements with the author.
17
-
18
- 3. You cannot distribute the software with/without modification or
19
- derived executable binary form without written arrangements with the author.
20
-
21
- 4. You may modify and include the part of the software into any other
22
- software.
23
-
24
- 5. The data supplied as input to or produced as output from the software
25
- do not automatically fall under the copyright of the software,
26
- but belong to whomever generated them.
27
-
28
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
29
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
30
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31
- PURPOSE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -3,7 +3,7 @@ when_exe - A multicultural and multilingualized calendar library
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/when_exe.svg)](http://badge.fury.io/rb/when_exe)
5
5
 
6
- [when_exe](http://rubygems.org/gems/when_exe) is a multicultural and multilingualized calendar library based on [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [ISO 19108](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26013), [RFC 5545(iCalendar)](http://tools.ietf.org/html/rfc5545) and [RFC6350](http://tools.ietf.org/html/rfc6350). [JSON-LD](http://www.w3.org/TR/json-ld/) formats for TemporalPosition and TemporalReferenceSystem are available.
6
+ [when_exe](http://rubygems.org/gems/when_exe) is a multicultural and multilingualized calendar library based on [ISO 8601:2004](https://en.wikipedia.org/wiki/ISO_8601), [ISO 19108](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26013), [RFC 5545(iCalendar)](http://tools.ietf.org/html/rfc5545) and [RFC6350](http://tools.ietf.org/html/rfc6350). [JSON-LD](http://www.w3.org/TR/json-ld/) formats for TemporalPosition and TemporalReferenceSystem are available.
7
7
 
8
8
  [<img alt='Architecture' title='display this figure at actual size' src='https://raw.githubusercontent.com/suchowan/when_exe/f7bb8b51259f0c1653c6c37b3ce20bd2a6ab7914/architecture.png' width='637' height='408'/>](https://raw.githubusercontent.com/suchowan/when_exe/f7bb8b51259f0c1653c6c37b3ce20bd2a6ab7914/architecture.png)
9
9
 
@@ -44,9 +44,9 @@ For further detail, please refer to the [when_exe Wiki](http://www2u.biglobe.ne.
44
44
  License
45
45
  -------
46
46
 
47
- This beta version's license is limited. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt) for details.
47
+ This beta version's license is the MIT license. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt).
48
48
 
49
- Data sets [TemporalPositionDataSet](http://hosi.org/tp.rdf) and [TemporalReferenceSystemDataSet](http://hosi.org/When.rdf) should be used according to [CC-BY-ND](http://creativecommons.org/licenses/by-nd/4.0/) license.
49
+ Data sets [TemporalPositionDataSet](http://hosi.org/tp.rdf) and [TemporalReferenceSystemDataSet](http://hosi.org/When.rdf) should be used according to [CC-BY](http://creativecommons.org/licenses/by/4.0/) license.
50
50
 
51
51
 
52
52
  Source Code
@@ -142,34 +142,18 @@ Example Usage
142
142
  # retrieve JSON, JSON-LD, Turtle response from http://hosi.org:3000 (when_exe demonstration web server)
143
143
  # (Notation3, RDF/XML, N-Triples and XML formats are also available.)
144
144
  require 'open-uri'
145
- open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
145
+ URI.open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
146
146
  puts json.read #=> newlines and blanks are inserted for readability.
147
147
  # {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
148
148
  # "precision": 0,
149
149
  # "location" : "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&alt=0.0",
150
150
  # "sdn" : 2456768,
151
151
  # "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
152
- # "notes" : [[{"note":"Month","value":"April"}],
153
- # [{"note":"Week","value":"Sunday(6)"}]],
154
- # "clock" : "Asia/Tokyo+09:00",
155
- # "clk_time" : [2456768,0,0,0],
156
- # "dynamical": 1397919667.184082,
157
- # "universal": 1397919600.0,
158
- # "cal_date" : [2014,4,20]}
159
- end
160
-
161
- open('http://hosi.org/tp/2014-04-20.json') do |json| # redirected from http://hosi.org to http://hosi.org:3000
162
- puts json.read #=> newlines and blanks are inserted for readability.
163
- # {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
164
- # "precision": 0,
165
- # "sdn" : 2456768,
166
- # "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
167
- # "notes" : [[{"note":"Month","value":"April"}],
168
- # [{"note":"Week","value":"Sunday(6)"}]],
152
+ # <..snip..>
169
153
  # "cal_date" : [2014,4,20]}
170
154
  end
171
155
 
172
- open('http://hosi.org/tp/2014-04-20.jsonld') do |jsonld| # redirected from http://hosi.org to http://hosi.org:3000
156
+ URI.open('http://hosi.org/tp/2014-04-20.jsonld') do |jsonld| # redirected from http://hosi.org to http://hosi.org:3000
173
157
  puts jsonld.read #=> newlines and blanks are inserted for readability.
174
158
  # {"@context":
175
159
  # {"xsd" :"http://www.w3.org/2001/XMLSchema",
@@ -196,7 +180,7 @@ Example Usage
196
180
  # }
197
181
  end
198
182
 
199
- open('http://hosi.org/tp/2014-04-20.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
183
+ URI.open('http://hosi.org/tp/2014-04-20.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
200
184
  puts ttl.read
201
185
  # @prefix Week: <http://hosi.org/When/Coordinates/Common::Week::> .
202
186
  # @prefix day: <http://hosi.org/When/CalendarNote/Christian/Notes::day::> .
@@ -216,7 +200,7 @@ Example Usage
216
200
  # ts:sdn 2456768 .
217
201
  end
218
202
 
219
- open('http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
203
+ URI.open('http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
220
204
  puts ttl.read
221
205
  # @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
222
206
  # @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@@ -296,42 +280,3 @@ Example Usage
296
280
  p When.when?('TZID=America/New_York:1997-10-26T02:30') #=> 1997-10-26T02:30-05:00
297
281
  p When.when?('TZID=America/New_York:1997-10-26T03:30') #=> 1997-10-26T03:30-05:00
298
282
 
299
- #
300
- # Google Calendar ------------------------------
301
- # https://rubygems.org/gems/google-api-client is required for this section's operations.
302
- # Please install google-api-client and add authorization file 'google-api.yaml' before operation.
303
-
304
- require 'google/api_client'
305
- require 'yaml'
306
- oauth_yaml = YAML.load_file('google-api.yaml')
307
- client = Google::APIClient.new(:application_name => 'when_exe',
308
- :application_version => When::VERSION)
309
- client.authorization.client_id = oauth_yaml['client_id']
310
- client.authorization.client_secret = oauth_yaml['client_secret']
311
- client.authorization.scope = oauth_yaml['scope']
312
- client.authorization.refresh_token = oauth_yaml['refresh_token']
313
- client.authorization.access_token = oauth_yaml['access_token']
314
- service = client.discovered_api('calendar', 'v3')
315
- calendar = When::GoogleAPI::Calendar.list(client, service,
316
- 'en.japanese#holiday@group.v.calendar.google.com')
317
- calendar.enum_for(When.when?('20150101/1231')).each do |date|
318
- p [date, date.events[0].summary] #=>
319
- # [2015-01-01, "New Year's Day"]
320
- # [2015-01-12, "Coming of Age Day"]
321
- # [2015-02-11, "National Foundation Day"]
322
- # [2015-03-21, "Spring Equinox"]
323
- # [2015-04-29, "Shōwa Day"]
324
- # [2015-05-03, "Constitution Memorial Day"]
325
- # [2015-05-04, "Greenery Day"]
326
- # [2015-05-05, "Children's Day"]
327
- # [2015-05-06, "Constitution Memorial Day observed"]
328
- # [2015-07-20, "Sea Day"]
329
- # [2015-09-21, "Respect for the Aged Day"]
330
- # [2015-09-22, "Bridge Public holiday"]
331
- # [2015-09-23, "Autumn Equinox"]
332
- # [2015-10-12, "Sports Day"]
333
- # [2015-11-03, "Culture Day"]
334
- # [2015-11-23, "Labor Thanksgiving Day"]
335
- # [2015-12-23, "Emperor's Birthday"]
336
- end
337
-
data/bin/make_ttl.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2014 Takashi SUGA
3
+ Copyright (C) 2014-2019 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license
6
6
  described in the LICENSE.txt file included in this archive.
@@ -24,7 +24,8 @@ File.open(config['file'], 'w') do |file|
24
24
  CONTEXT.each_pair do |key, value|
25
25
  file.puts "@prefix #{key}: <#{value}> ."
26
26
  end
27
- (when?(config['begin'])..when?(config['end'])).each do |date|
27
+ (config['begin'].to_i..config['end'].to_i).each do |year|
28
+ date = when?("#{year}^^#{year < 1873 ? 'Japanese' : 'Gregorian?note=Japanese'}")
28
29
  graph = RDF::Graph.new <<
29
30
  JSON::LD::API.toRdf(date.rdf_graph(
30
31
  {'@context'=>CONTEXT, :prefixes=>PREFIXES, :included=>true, :include=>true}))
@@ -1,6 +1,6 @@
1
- {"begin" : "593^^Japanese",
2
- "end" : "1872^^Japanese",
3
- "file" : "japanese.ttl",
1
+ {"begin" : "593",
2
+ "end" : "2051",
3
+ "file" : "notes_data_japan.ttl",
4
4
  "resource" : [
5
5
  "_co:Common",
6
6
  "_co:Common?V=0618",
data/lib/when_exe.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2016 Takashi SUGA
3
+ Copyright (C) 2011-2019 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -260,6 +260,7 @@ module When
260
260
  autoload :Iranian, 'when_exe/region/iranian'
261
261
  autoload :Bahai, 'when_exe/region/bahai'
262
262
  autoload :Islamic, 'when_exe/region/islamic'
263
+ autoload :SaudiArabia, 'when_exe/region/saudi_arabian'
263
264
  autoload :Jewish, 'when_exe/region/jewish'
264
265
  autoload :AncientOrient, 'when_exe/region/babylonian'
265
266
  autoload :Armenian, 'when_exe/region/armenian'
@@ -324,6 +325,8 @@ module When
324
325
  autoload :IndianNationalSolar, 'when_exe/region/indian'
325
326
  autoload :Nanakshahi, 'when_exe/region/indian'
326
327
  autoload :RevisedBengali, 'when_exe/region/indian'
328
+ autoload :VikramSambatSolar, 'when_exe/region/indian'
329
+ autoload :VikramSamvatSolar, 'when_exe/region/indian'
327
330
  autoload :HinduLuniSolar, 'when_exe/region/indian'
328
331
  autoload :HinduSolar, 'when_exe/region/indian'
329
332
  autoload :Jalali, 'when_exe/region/iranian'
@@ -339,6 +342,7 @@ module When
339
342
  autoload :Bahai, 'when_exe/region/bahai'
340
343
  autoload :TabularIslamic, 'when_exe/region/islamic'
341
344
  autoload :EphemerisBasedIslamic, 'when_exe/region/islamic'
345
+ autoload :UmmalquraSolar, 'when_exe/region/saudi_arabian'
342
346
  autoload :Jewish, 'when_exe/region/jewish'
343
347
  autoload :Hebrew, 'when_exe/region/jewish'
344
348
  autoload :Armenian, 'when_exe/region/armenian'
@@ -529,7 +533,8 @@ module When
529
533
  ['[M=,alias:明=ja:%%<明治>]6.01.01', '@CR', '1873-01-01^Gregorian?note=Default'],
530
534
  ['[T=,alias:大=ja:%%<大正>]1.07.30', '@A', '1912-07-30'],
531
535
  ['[S=,alias:昭=ja:%%<昭和>]1.12.25', '@A', '1926-12-25'],
532
- ['[H=,alias:平=ja:%%<平成>]1.01.08', '@A', '1989-01-08']
536
+ ['[H=,alias:平=ja:%%<平成>]1.01.08', '@A', '1989-01-08'],
537
+ ['[R=,alias:令=ja:%%<令和>]1.05.01', '@A', '2019-05-01']
533
538
  ]]
534
539
  end
535
540
  end
@@ -970,7 +975,7 @@ module When
970
975
  locale = options.delete(:locale) || 'en'
971
976
  title = EncodingConversion.to_internal_encoding(title)
972
977
  entry, query = title.split('?', 2)
973
- url = "https://#{locale}.wikipedia.org/wiki/#{URI.encode(entry).gsub(' ', '_')}"
978
+ url = "https://#{locale}.wikipedia.org/wiki/#{CGI.escape(entry).gsub(' ', '_')}"
974
979
  Locale.send(:wikipedia_object, url, options) unless options.empty?
975
980
  url += '?' + query if query
976
981
  object = Parts::Resource._instance(url)
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2016 Takashi SUGA
3
+ Copyright (C) 2011-2021 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -109,7 +109,6 @@ module When
109
109
  # extended date & time format (JIS X0301)
110
110
  when /\A((.+::)?(\[[^\]]+\]|[^-+\d{]+))(([-+*&%@!>=<?\dW.\(\)]|\{.+?\})+)?(?:(T([:*=.,\d]+)?)([A-Z]+(\?.+)?|[-+][:\d]+)?)?\z/
111
111
  era, parent, child, d, v, t, time, clock = $~[1..8]
112
- d0 = d
113
112
  d, r = _split_residue(d, options[:abbr]) if d =~ /\{/
114
113
  format, date, era = Date._to_array_extended_X0301(d, era, options)
115
114
  era ||= options[:era_name] if d =~ /\./
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2015 Takashi SUGA
3
+ Copyright (C) 2011-2021 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -108,7 +108,7 @@ module When
108
108
  #
109
109
  # @return [Array] ハッシュ要素からなる配列(元の構造が配列であった場合)
110
110
  #
111
- # @note 引数 symbol が Integer の場合は添え字とみなして元の配列の要素を取り出す
111
+ # @note 引数 symbol が Symbol でも String でもない場合は添え字とみなして元の配列の要素を取り出す
112
112
  #
113
113
  def value(compact=true, symbol=:value)
114
114
  if kind_of?(Hash) && !key?(:note)
@@ -119,8 +119,12 @@ module When
119
119
  end
120
120
  else
121
121
  # Non-Persistent NotesContainer
122
- return _bless(slice(symbol)) if symbol.kind_of?(Integer)
123
- sliced = _dig(self) {|target| target.fetch(symbol, nil)}
122
+ case symbol
123
+ when Symbol, String
124
+ sliced = _dig(self) {|target| target.fetch(symbol, nil)}
125
+ else
126
+ return _bless(slice(symbol))
127
+ end
124
128
  end
125
129
  sliced = _bless(sliced)
126
130
  compact ? sliced.simplify : sliced
@@ -325,7 +329,7 @@ module When
325
329
  def notes(date, options={})
326
330
  dates, indices, notes, persistence, conditions, options = _parse_note(date, options)
327
331
  retrieved = NotesContainer.retrieve(persistence, date.to_i)
328
- return retrieved unless retrieved == false
332
+ return retrieved if retrieved
329
333
  NotesContainer.register(indices.map {|i|
330
334
  next [] unless i <= date.precision
331
335
  _note_values(dates, notes[i-1], _all_keys[i-1], _elements[i-1]) do |dates, focused_notes, notes_hash|
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2016 Takashi SUGA
3
+ Copyright (C) 2011-2021 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -419,7 +419,7 @@ module When::CalendarTypes
419
419
 
420
420
  # mean month length
421
421
  if @entry_key
422
- ::Rational
422
+ Rational
423
423
  @mean_month = Rational(@rule_table[@entry_key]['Days'], @rule_table[@entry_key]['Months'])
424
424
  @mean_year = Rational(@rule_table[@entry_key]['Days'], @rule_table[@entry_key]['Years' ])
425
425
  end
@@ -609,7 +609,7 @@ module When::CalendarTypes
609
609
  difference.each_pair do |year, pattern|
610
610
  offset = year - hash['origin_of_MSC']
611
611
  hash['rule_table'][offset] =
612
- if pattern.kind_of?(Hash)
612
+ if pattern.kind_of?(Hash)
613
613
  rule = hash['rule_table'][offset].dup
614
614
  pattern.each_pair do |key,value|
615
615
  raise ArgumentError, "Can't patch \"#{rule}\" by {#{key}=>#{value}} at #{year}" unless rule.sub!(key,value)
@@ -1294,7 +1294,7 @@ module When::CalendarTypes
1294
1294
  "Formula?formula=#{@months_in_year||12}S" : 'SolarFormulaWithTable')
1295
1295
  super
1296
1296
  end
1297
- end
1297
+ end
1298
1298
 
1299
1299
  # 月日の配当が月の位相によって決定される純太陰暦
1300
1300
  #
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2015 Takashi SUGA
3
+ Copyright (C) 2011-2021 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -933,8 +933,8 @@ module When::Coordinates
933
933
  when nil
934
934
  form += c
935
935
  else
936
- suffix = DL2[m17ns[i ? i.to_i : index]*0] || s if s
937
- form += t + ({nil=>'', '%'=>'%%'}[suffix] || suffix)
936
+ suffix = DL2[m17ns[i ? i.to_i : index] * 0] || s if s
937
+ form += t + ({nil=>'', '%'=>'%%'}[suffix] || suffix)
938
938
  index += t.length - t.gsub(/\*/,'').length + 1
939
939
  end
940
940
  form
@@ -947,14 +947,14 @@ module When::Coordinates
947
947
  #
948
948
  # @return [Numeric] 年番号,月番号,日番号など暦要素の幹となる部分
949
949
  #
950
- attr_accessor :trunk
950
+ attr_reader :trunk
951
951
 
952
952
  #
953
953
  # 暦要素の枝
954
954
  #
955
955
  # @return [Numeric] 暦要素のうち(閏であるかなど)幹で表現しきれない枝の部分
956
956
  #
957
- attr_accessor :branch
957
+ attr_reader :branch
958
958
 
959
959
  #
960
960
  # 暦要素の幹と枝の和
@@ -1110,6 +1110,15 @@ module When::Coordinates
1110
1110
  return @trunk.to_s + (@branch==0 ? zero : DL2[@branch])
1111
1111
  end
1112
1112
 
1113
+ # 整数化
1114
+ # Array の index 値を提供する場合に呼ばれる
1115
+ #
1116
+ # @return [Integer]
1117
+ #
1118
+ def to_i
1119
+ @sum.to_i
1120
+ end
1121
+
1113
1122
  # 強制型変換
1114
1123
  # @private
1115
1124
  def coerce(other)
@@ -1137,19 +1146,6 @@ module When::Coordinates
1137
1146
  @sum += @branch if (@trunk)
1138
1147
  end
1139
1148
  end
1140
-
1141
- # その他のメソッド
1142
- # When::Coordinates:Pair で定義されていないメソッドは
1143
- # 処理を @sum (type:Numeric) に委譲する
1144
- #
1145
- def method_missing(name, *args, &block)
1146
- self.class.module_eval %Q{
1147
- def #{name}(*args, &block)
1148
- @sum.send("#{name}", *args, &block)
1149
- end
1150
- } unless When::Parts::MethodCash.escape(name)
1151
- @sum.send(name, *args, &block)
1152
- end
1153
1149
  end
1154
1150
 
1155
1151
  # 暦座標値
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2016 Takashi SUGA
3
+ Copyright (C) 2011-2021 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -1959,7 +1959,7 @@ module When::Ephemeris
1959
1959
  @year_epoch = @year_epoch.to_f
1960
1960
  else
1961
1961
  @year_epoch = 0
1962
- @year_epoch = @longitude_shift -_mean_sun_(@epoch_shift).to_i
1962
+ @year_epoch = @longitude_shift - _mean_sun_(@epoch_shift).to_i
1963
1963
  end
1964
1964
  @cycle_precision ||= 1.0E-8
1965
1965
  @cycle_precision = @cycle_precision.to_f
@@ -1973,7 +1973,7 @@ module When::Ephemeris
1973
1973
  @month_epoch = @month_epoch.to_f
1974
1974
  else
1975
1975
  @month_epoch = 0
1976
- @month_epoch = @longitude_shift -_mean_moon_(@epoch_shift).to_i
1976
+ @month_epoch = @longitude_shift - _mean_moon_(@epoch_shift).to_i
1977
1977
  end
1978
1978
  extend LunarMethod
1979
1979
  else
@@ -1983,9 +1983,8 @@ module When::Ephemeris
1983
1983
  end
1984
1984
 
1985
1985
  # 通法
1986
- @denominator = @year_length.denominator if @year_length.kind_of?(Rational)
1987
- @denominator = [@denominator||0, @lunation_length.denominator].max if @lunation_length.kind_of?(Rational)
1988
-
1986
+ @denominator = @denominator.to_i if @denominator
1987
+ @denominator ||= [@year_length, @lunation_length].map {|length| length.kind_of?(Rational) ? length.denominator : 0}.max
1989
1988
  super
1990
1989
  end
1991
1990
  end