astro_calc 0.2.3 → 0.2.4
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 +4 -4
- data/lib/astro_calc/moon_phases.rb +22 -38
- data/lib/astro_calc/version.rb +1 -1
- data/vendor/assets/images/starfield.png +0 -0
- data/vendor/assets/stylesheets/astro.css.scss +5 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a8e0b60b8e1b16a575cb20d2efa86f535aecffa
|
4
|
+
data.tar.gz: 0f136bbcfc26c4e90fd905ada9fbbefa2907b902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3dab24f219f3fd660223073ee66a52a2e966628261d1a5686cc7c73fde3c13f3d16eacbb5535cbdd0c3005c00ba3b61448aa5b57acef14f6a7aa347e441a6be
|
7
|
+
data.tar.gz: 1f990ba295a59e20ae0c27bb8014676b5f7d9169dc12411e4d6832bcd1832a0b68fb16fc2560df624b9ba4d9d360c958c8d1b82123adf275c6882313da6d5823
|
@@ -7,16 +7,21 @@ class MoonPhases
|
|
7
7
|
LIMIT_JULIAN_CALENDAR = 2299160
|
8
8
|
JULIAN_DAYS_IN_MONTH = 29.530588853
|
9
9
|
|
10
|
-
attr_reader :phase, :age, :distance, :latitude, :longitude, :constellation
|
10
|
+
attr_reader :phase, :age, :distance, :latitude, :longitude, :constellation, :date
|
11
11
|
attr_reader :sweep, :magnitude # for svg
|
12
12
|
|
13
13
|
attr_reader :detailed_position, :detailed_age, :detailed_distance, :detailed_constellation
|
14
14
|
|
15
15
|
|
16
16
|
def initialize(date = Date.today)
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
@date = date
|
18
|
+
perform_calculations
|
19
|
+
end
|
20
|
+
|
21
|
+
def perform_calculations
|
22
|
+
year = @date.year
|
23
|
+
month = @date.month
|
24
|
+
day = @date.day
|
20
25
|
|
21
26
|
#calculate the Julian date at 12h UT
|
22
27
|
y = year - ((12 - month) / 10.0).floor
|
@@ -113,47 +118,26 @@ class MoonPhases
|
|
113
118
|
# @return [String] the unicode string showing the moon phase
|
114
119
|
def unicode
|
115
120
|
case @phase
|
116
|
-
when 0.0625..0.1875 then "
|
117
|
-
when 0.1875..0.3125 then "
|
118
|
-
when 0.3125..0.4375 then "
|
119
|
-
when 0.4375..0.5625 then "
|
120
|
-
when 0.5625..0.6875 then "
|
121
|
-
when 0.6875..0.8125 then "
|
122
|
-
when 0.8125..0.9375 then "
|
123
|
-
else "
|
121
|
+
when 0.0625..0.1875 then "🌒"
|
122
|
+
when 0.1875..0.3125 then "🌓"
|
123
|
+
when 0.3125..0.4375 then "🌔"
|
124
|
+
when 0.4375..0.5625 then "🌕"
|
125
|
+
when 0.5625..0.6875 then "🌖"
|
126
|
+
when 0.6875..0.8125 then "🌗"
|
127
|
+
when 0.8125..0.9375 then "🌘"
|
128
|
+
else "🌑"
|
124
129
|
end
|
125
130
|
end
|
126
131
|
|
127
132
|
# Calculates the magnification for a given telescope and eyepiece
|
128
133
|
#
|
129
|
-
# @param options [Hash] the options for SVG generation
|
130
134
|
# @return [String] the SVG output
|
131
|
-
def svg
|
132
|
-
default_options = {
|
133
|
-
include_style: true,
|
134
|
-
height: "200px",
|
135
|
-
background_color: "#111111",
|
136
|
-
left: "35%",
|
137
|
-
top: "75px",
|
138
|
-
moon_color: "#CDCDCD",
|
139
|
-
shadow_color: "#000000"
|
140
|
-
}
|
141
|
-
options = default_options.merge(options)
|
142
|
-
|
135
|
+
def svg
|
143
136
|
output = ""
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
output << "#moon { position:absolute; left:#{options[:left]}; top:#{options[:top]}; }"
|
149
|
-
output << ".moon { fill: #{options[:moon_color]}; }"
|
150
|
-
output << ".moonback { stroke: #{options[:shadow_color]}; stroke-width: 1px; height: 180px; }"
|
151
|
-
output << "</style>"
|
152
|
-
end
|
153
|
-
|
154
|
-
output << "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100% 100%' version='1.1' id='moon'>"
|
155
|
-
output << " <path d='m100,0 a20,20 0 1,1 0,150 a20,20 0 1,1 0,-150' class='moonback'></path>"
|
156
|
-
output << " <path d='m100,0 a#{@magnitude.round(2)},20 0 1,#{@sweep[0]} 0,150 a20,20 0 1,#{@sweep[1]} 0,-150' class='moon'></path>"
|
137
|
+
output << "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100% 100%' version='1.1' id='moon_phase'>"
|
138
|
+
output << "<path d='m100,0 a20,20 0 1,1 0,150 a20,20 0 1,1 0,-150' class='moon_back'></path>"
|
139
|
+
output << "<image xlink:href='moon.jpg; x='0' y='0' height='200px' width='200px'/>"
|
140
|
+
output << "<path d='m100,0 a#{@magnitude.round(2)},20 0 1,#{@sweep[0]} 0,150 a20,20 0 1,#{@sweep[1]} 0,-150' class='moon'></path>"
|
157
141
|
output << "</svg>"
|
158
142
|
output.html_safe
|
159
143
|
end
|
data/lib/astro_calc/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,5 @@
|
|
1
|
+
.moon_back { background-image: image-url('starfield.png') !important; height: 200px; }
|
2
|
+
.moon { background-image: image-url("moon.png"); }
|
3
|
+
|
4
|
+
.moon_back { height: 200px; background-color: #000000; }
|
5
|
+
.moon_phase { position:absolute; left:35%; top:75px; stroke: #999999; stroke-width: 1px; height: 180px; }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astro_calc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reuben Mallaby
|
@@ -76,6 +76,8 @@ files:
|
|
76
76
|
- lib/astro_calc/telescopes.rb
|
77
77
|
- lib/astro_calc/version.rb
|
78
78
|
- vendor/assets/images/moon.png
|
79
|
+
- vendor/assets/images/starfield.png
|
80
|
+
- vendor/assets/stylesheets/astro.css.scss
|
79
81
|
homepage: http://mallaby.me/projects/astro_calc
|
80
82
|
licenses:
|
81
83
|
- MIT
|