british_suntimes 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/british_suntimes.rb +31 -1
- metadata +41 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e31bfb164e63efe50333e5f978407ccf986cf3a75790381226a0ea58a098677b
|
4
|
+
data.tar.gz: 8bc2366559d43a75dda383affaaef0bf5c5f6fe3b58deb85024aaa03bf513204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa68395c9d21f404c265b5b05107e781809b92e5b7351fba3fa8fb09792cf47fa4427d069d7d80f1b16d672583db4c13ad7cdfe3fc9a3ef87c547277a4063b9a
|
7
|
+
data.tar.gz: 50e928228ed848f69021d58ace156375584d765e4600ccf19242e2278ea04203ff4e851730dabb4be4124e2a3749eab70ef396fb798439090eb797404012a204
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/british_suntimes.rb
CHANGED
@@ -8,6 +8,9 @@ require 'geocoder'
|
|
8
8
|
require 'chronic_cron'
|
9
9
|
require 'solareventcalculator'
|
10
10
|
|
11
|
+
require 'subunit'
|
12
|
+
require 'human_speakable'
|
13
|
+
|
11
14
|
|
12
15
|
|
13
16
|
class BritishSuntimes
|
@@ -18,7 +21,7 @@ class BritishSuntimes
|
|
18
21
|
def initialize(year=Date.today.year.to_s, location: 'edinburgh',
|
19
22
|
debug: false)
|
20
23
|
|
21
|
-
@debug = debug
|
24
|
+
@location, @debug = location, debug
|
22
25
|
|
23
26
|
a = (Date.parse(year + ' Jan')...Date.parse(year.succ + ' Jan')).to_a
|
24
27
|
g = Geocoder.search(location)
|
@@ -89,6 +92,33 @@ class BritishSuntimes
|
|
89
92
|
|
90
93
|
end
|
91
94
|
|
95
|
+
class BritishSuntimesAgent < BritishSuntimes
|
96
|
+
using HumanSpeakable
|
97
|
+
using Ordinals
|
98
|
+
|
99
|
+
|
100
|
+
def longest_day()
|
101
|
+
|
102
|
+
d = super()
|
103
|
+
days = (Date.parse(d) - Date.today).to_i
|
104
|
+
sunrise, sunset = to_dx().to_h[d]
|
105
|
+
|
106
|
+
t1 = Time.parse(d + ' ' + sunrise)
|
107
|
+
t2 = Time.parse(d + ' ' + sunset)
|
108
|
+
|
109
|
+
su = Subunit.new(units={minutes:60, hours:60}, seconds: (t2 - t1).to_i)
|
110
|
+
duration = su.to_s omit: [:seconds]
|
111
|
+
|
112
|
+
d2 = Date.parse(d)
|
113
|
+
day = d2.strftime("#{d2.day.ordinal} %B")
|
114
|
+
|
115
|
+
s = d2.humanize
|
116
|
+
msg = s[0].upcase + s[1..-1] + " (%s), is the longest day of the year when #%s will enjoy %s of sunshine. The sun will rise at %sam and set at %spm." % [day, @location, duration, t1.strftime("%-I:%M"), t2.strftime("%-I:%M")]
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
92
122
|
|
93
123
|
if __FILE__ == $0 then
|
94
124
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: british_suntimes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -117,6 +117,46 @@ dependencies:
|
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: 0.3.3
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
name: subunit
|
122
|
+
requirement: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 0.5.0
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0.5'
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 0.5.0
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.5'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: human_speakable
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 0.2.0
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0.2'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 0.2.0
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.2'
|
120
160
|
description:
|
121
161
|
email: james@jamesrobertson.eu
|
122
162
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|