Module: SKY
- Defined in:
- lib/toychest/sky.rb
Class Method Summary collapse
Class Method Details
.at(h = {}, &b) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/toychest/sky.rb', line 2 def self.at(h={}, &b) h = { phase: SunCalc.moon_illumination(h[:date]), moon: SunCalc.moon_position(h[:date], h[:lat], h[:lon]), night: SunCalc.moon_times(h[:date], h[:lat], h[:lon]), sun: SunCalc.sun_position(h[:date], h[:lat], h[:lon]), day: SunCalc.sun_times(h[:date], h[:lat], h[:lon]) } if block_given? return b.call(h) else return h end end |
.now(&b) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/toychest/sky.rb', line 16 def self.now &b utc = Time.now.utc now = Time.now m = Lunartic.on_date(DateTime.new(now.year, now.month, now.day, now.hour, now.min, now.sec)) t = SunCalc.moon_illumination(now)[:phase] h = { epoch: utc.to_i, day: m.day, phase: m.phase, full: m.percent_full, moon: t, now: now } if block_given? return b.call(h) else return h end end |