class MoonInfo
Constants
- EMOJI
This service is built for the 'moonPhase' variable in the DarkSky API where a 'new' moon is 0 (0.99, 0, and 0.01) and a 'full' moon is 0.5 (0.49 - 0.51)
Attributes
cycle_completion[R]
Public Class Methods
new(cycle_completion)
click to toggle source
# File lib/meteorologist/moon_info.rb, line 17 def initialize(cycle_completion) @cycle_completion = cycle_completion end
Public Instance Methods
active_elements()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 58 def active_elements return [] @active_elements ||= build_active_elements end
emoji()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 63 def emoji EMOJI[phase_name] end
illumination()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 21 def illumination return 0 if new? return 1 if full? if waxing? ((cycle_completion / 0.48) - 0.01).round(2) else (1 - ((cycle_completion - 0.51) / 0.48)).round(2) end end
in_sign()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 54 def in_sign #MoonSignCalculator.calculate(date) end
phase_name()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 39 def phase_name return 'new' if new? return 'full' if full? if waxing? return 'crescent' if crescent? return 'first quarter' if quarter? return 'gibbous' if gibbous? else return 'disseminating' if gibbous? return 'last quarter' if quarter? return 'balsamic' if crescent? end end
waning?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 35 def waning? cycle_completion.between?(0.51, 0.98) end
waxing?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 31 def waxing? cycle_completion.between?(0.02, 0.48) end
Private Instance Methods
crescent?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 75 def crescent? cycle_completion.between?(0.02,0.23) || cycle_completion.between?(0.77,0.98) end
full?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 87 def full? cycle_completion.between?(0.49,0.51) end
gibbous?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 83 def gibbous? cycle_completion.between?(0.27,0.48) || cycle_completion.between?(0.52,0.73) end
new?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 71 def new? cycle_completion > 0.98 || cycle_completion < 0.02 end
quarter?()
click to toggle source
# File lib/meteorologist/moon_info.rb, line 79 def quarter? cycle_completion.between?(0.24,0.26) || cycle_completion.between?(0.74,0.76) end